- Learn C# in 7 days
- Gaurav Aroraa
- 179字
- 2021-07-08 09:51:22
3 (Day02)
This is the namespace of our existing console application.
A namespace is a way to keep one set of names separate from another, which means you can create as many namespaces as you want and the classes under different namespaces will treat them as a separate, although they have the same name; that is, if you declare a ClassExample class in namespace Day02, it would be different from the ClassExample class declared in the Day02New namespace and will work without any conflicts.
This is a typical example that shows two classes of the same name with two different namespaces:
namespace Day02 { public class ClassExample { public void Display() { Console.WriteLine("This is a class 'ClassExample' of namespace 'Day02'. "); } } } namespace Day02New { public class ClassExample { public void Display() { Console.WriteLine("This is a class 'ClassExample' of namespace 'Day02New'. "); } } }
The preceding code would be called like this:
private static void SameClassDifferentNamespacesExample() { var class1 = new ClassExample(); var class2 = new Day02New.ClassExample(); class1.Display(); class2.Display(); }
This will return the following output:

推薦閱讀
- Extending Jenkins
- Responsive Web Design with HTML5 and CSS3
- MySQL 8 DBA基礎教程
- 飛槳PaddlePaddle深度學習實戰
- ASP.NET Core 2 Fundamentals
- Learning R for Geospatial Analysis
- INSTANT Adobe Edge Inspect Starter
- .NET 4.5 Parallel Extensions Cookbook
- Laravel Application Development Blueprints
- Scala編程實戰
- 深入解析Java編譯器:源碼剖析與實例詳解
- H5+移動營銷設計寶典
- UML基礎與Rose建模實用教程(第三版)
- 啊哈C語言!:邏輯的挑戰(修訂版)
- Mapping with ArcGIS Pro