Search code examples
c#winformsvisual-studiovisual-studio-2012windows-phone-8

How do I call a class contained in a folder in C#/Visual Studio?


enter image description here enter image description here

This is probably a very stupid question;

I've just been attempting to make my first Universal App in Visual Studio. Anyway, I'm attempting to make a class file which can be called from both the Phone and Store app, however, VS keeps storing this .cs file in a folder.

How can I call the class when it's in a folder?

Normally I'd just do something like:

ClassName class1 = new ClassName()

but this won't work as I don't know how to put the folder in their, if you know what I mean; I've tried

FolderName.ClassName() class1 = new FolderName.ClassName() but to no avail.

Can someone tell me how to reference a class contained in a folder?

Thanks.

Edit: I've added an image. I'm trying to access a method contained in Print.cs in MainPage.xaml.cs

ANSWER: Put classes that I intend to share in the "UniApp1.Shared" folder (Duh!) :/


Solution

  • You have added your class into solution items. Solution items are not compiled into your project's output. Simply move the class into your project (a simple drag-n-drop should do) and it will work fine.