namespace C# with Example



namespace C# with Example

The namespace keyword is an organization construct that helps us understand how a codebase is arranged. 
Namespaces in C# are virtual spaces rather than being in a physical folder. 
namespace StackOverflow 
{ 
namespace Documentation 
{ 
namespace CSharp.Keywords 
{ 
 

public class Program 
{ 
public static void Main() 
{ 
Console.WriteLine(typeof(Program).Namespace); 
//StackOverflow.Documentation.CSharp.Keywords 
} 
} 
} 
} 
} 
Namespaces in C# can also be written in chained syntax. The following is equivalent to above: 
namespace StackOverflow.Documentation.CSharp.Keywords 
{ 
public class Program 
{ 
public static void Main() 
{ 
Console.WriteLine(typeof(Program).Namespace); 
//StackOverflow.Documentation.CSharp.Keywords 
} 
} 
} 

0 Comment's

Comment Form

Submit Comment