0

I have c# file with all contents contained in a namespace LinkedList saved with the name linkedlist.cs . This file doesn't have a main() method. I want to include the content of that file or that namespace in another file.

How can I do that ?

Manish Singh
  • 360
  • 1
  • 6
  • 18
  • Another file in the same project? or are you trying to add it to another project? Perhaps reading [this](http://msdn.microsoft.com/en-gb/library/z2kcy19k.aspx) and [this](http://msdn.microsoft.com/en-us/library/sf0df423.aspx) will be of some help – musefan Aug 20 '14 at 15:04
  • 2
    Add it to a project, and in the other file add `using LinkedList;`? – cdhowie Aug 20 '14 at 15:05
  • 1
    what kind of content u have ? under a name space you can only host classes, enumerations, delegates interfaces and struct. if your content is a class you should instantiate it unless it is static.and in all cases you have to follow what cdhowie said. – Sam Aug 20 '14 at 15:15
  • thanks for this help, but if I wanted to do the same in linux (without any ide) using dmcs compiler? How can do that? – Manish Singh Aug 21 '14 at 18:31

1 Answers1

0

Assuming your LinkedList is in a project called MyLinkedListProject, you will want to reference this project from the project inheriting it. As stated in the comments by @cdhowie you can then reference the namespace by adding the using LinkedList; which will reference the namespace.

Depending on the content of linkedlist.cs will depend on how you access it, assuming it contains a class called LinkedList within the LinkedList you would access the methods (of the class using code such as LinkedList.methodName(); (this would work for a static method, you'd have to instantiate a LinkedList first if you require an "instance of the object" for the method to work.

talegna
  • 2,407
  • 2
  • 19
  • 22