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
Post a Comment