名稱空間與巢狀命名中的處理

iamzxf發表於2015-03-09


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NamespaceTest
{
    class SampleClass
    {
        public void SampleMethod()
        {
            Console.WriteLine("SampleMethod indide namespaceTest");
        }
    }
    namespace nestedNamespace
    {
        class SampleClass
        {
            public void SampleMethod()
            {
                Console.WriteLine("SampleMethod indide nested namespaceTest");
            }
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            SampleClass outer = new SampleClass();
            outer.SampleMethod();
            NamespaceTest.SampleClass outer2 = new NamespaceTest.SampleClass();
            outer2.SampleMethod();

            nestedNamespace.SampleClass inner = new nestedNamespace.SampleClass();
            inner.SampleMethod();
            NamespaceTest.nestedNamespace.SampleClass inner2 = new NamespaceTest.nestedNamespace.SampleClass();
            inner2.SampleMethod();

        }
    }
}




相關文章