using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SampleNamespace { class SampleClass { public void SampleMethod() { Console.WriteLine("主命名空间SampleNamespace的方法被调用"); } } namespace NestedNamespace { class SampleClass { public void SampleMethod() { Console.WriteLine("嵌套的命名空间的方法被调用"); } } } class Program { static void Main() { SampleClass outer = new SampleClass(); outer.SampleMethod(); NestedNamespace.SampleClass inner = new NestedNamespace.SampleClass(); inner.SampleMethod(); } } }