本文整理汇总了C#中Class1.AMethod方法的典型用法代码示例。如果您正苦于以下问题:C# Class1.AMethod方法的具体用法?C# Class1.AMethod怎么用?C# Class1.AMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Class1
的用法示例。
在下文中一共展示了Class1.AMethod方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
// Create an instance of Main's own class.
Class1 c1 = new Class1(); // MainCode.Class1.
c1.AMethod();
// Create an instance of LibraryCode1.Class1.
// The following just creates a new MainCode.Class1,
// not what you intended; no using directive and
// not fully qualified.
Class1 c2 = new Class1(); // Ambiguous without qualification.
c2.AMethod();
// But a qualified name does create the right class.
// Must qualify this even given the using directive, since
// both namespaces have a Class1.
LibraryCode1.Class1 c3 = new LibraryCode1.Class1();
c3.AMethod();
// Meanwhile, creating a LibraryCode1.Class2 doesn't require
// qualification because there's a using directive and
// no name clash.
Class2 c4 = new Class2();
c4.AMethod();
// Create an instance of LibraryCode2.Class1.
// Requires qualification, both because there is no using
// directive for LibraryCode2 and both namespaces have a Class1.
//
// Note: also works even though LibraryCode2.Class1 is
// declared internal, not public, because both classes
// are in the same compiled assembly.
LibraryCode2.Class1 c5 = new LibraryCode2.Class1();
c5.AMethod();
Console.WriteLine("Press Enter to terminate...");
Console.Read();
}