-6

I'm trying to create a static class (IntNode, IntList) that I would be able to access through any project by using the class name.

I've saved the file name as the class name (IntNode.cs), and I added public before the class name, but still it is not recognized on other projects.

What else I'm missing?

George Duckett
  • 31,770
  • 9
  • 95
  • 162
  • 1
    How to add reference to outer file http://stackoverflow.com/questions/3599722/using-a-class-file-reference-it – Alex Apr 24 '13 at 13:28
  • http://iampierremenard.files.wordpress.com/2012/01/dog-dude-wait-what.jpg – Soner Gönül Apr 24 '13 at 13:28
  • 2
    @ByteBlast: Or just someone at the very beginning of his journey. – Daniel Hilgarth Apr 24 '13 at 13:34
  • This question is incomplete. Please tell us what is the context, are you in the same solution? – Jean-François Côté Apr 24 '13 at 13:47
  • yes, i am in the beginning of my journey, and no, i am NOT a troll. @ByteBlast - you must have a very exciting life behind your keyboard. i'm studying out of a very doughtful book in a language that is definitely not english, so i'm trying my best to be clear. i understood that it is possible to create a class that doesn't have a Main method. just includes a lot of methods that are commonly used (for example - dealing with arrays - reading, writing, calculations Etc.) once existing, is it possible to use from a different solution without copying the file into the current solution? – user2315710 Apr 24 '13 at 17:58
  • @user2315710 misunderstanding, sorry. – User 12345678 Apr 24 '13 at 17:59

1 Answers1

4

The projects that want to use that class need to do one of the following two things:

  1. Reference the assembly the classes have been defined in.
  2. Directly add the *.cs files to the project. You can add them as a local copy or as a link.

Option 1 is preferred.

Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443
  • 1
    @GeorgeDuckett: Thanks, I added that. In this scenario, it would be unusual, but there are other scenarios where it is very common, e.g. app development via Xamarin. The code can be the same for different platforms, but you need one project file per platform. – Daniel Hilgarth Apr 24 '13 at 13:31
  • 1
    (Deleted my original comment suggesting adding option 2 once you'd done that). It's also common when dealing with [tag:XNA] (one project for each target platform) which is where I've used it in the past. – George Duckett Apr 24 '13 at 13:34