namespace Microsoft.Sample{using Guid = System.Guid;public class Guid{public Guid(string s){}}
public class Program{public static void Main(string[] args){Guid g = new Guid("hello");}}}
代码在以下编译器错误中失败,该错误位于包含Guid g = new Guid("hello");的行中
namespace MyCorp.TheProduct.SomeModule.Utilities{using System;using System.Collections.Generic;using System.Linq;using MyCorp.TheProduct; // MyCorp can be left out; this using is NOT redundantusing MyCorp.TheProduct.OtherModule; // MyCorp.TheProduct can be left outusing MyCorp.TheProduct.OtherModule.Integration; // MyCorp.TheProduct can be left outusing ThirdParty;
class C{Ambiguous a;}}
//file1.csnamespace Foo{class Foo{}}
//file2.csnamespace ConsoleApp3{using Foo;class Program{static void Main(string[] args){//This will allow you to use the classFoo test = new Foo();}}}
//file3.csusing Foo; //Unused and redundantnamespace Bar{class Bar{Bar(){Foo.Foo test = new Foo.Foo();Foo test = new Foo(); //will give you an error that a namespace is being used like a class.}}}