How does connecting Namespaces work in C#? -


i new c# , trying print out number different namespace in main. provide code below.

using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks;  namespace consoleapplication1 {     class program     {         static void main(string[] args)         {             console.writeline("hello world" + x);             console.readline();         }     } }  namespace applicaton {      class program2     {         public int test()         {             int x = 5;             return x;         }     } } 

i want have x program2 class appear in main in program class.

just call class.

 program2 p = new program2();  console.writeline(p.test().tostring()); 

and ever program2 have can call on it. or assign it.

int num = p.test(); console.writeline(num); 

then print it.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -