本文整理汇总了C#中Example.GetN方法的典型用法代码示例。如果您正苦于以下问题:C# Example.GetN方法的具体用法?C# Example.GetN怎么用?C# Example.GetN使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Example
的用法示例。
在下文中一共展示了Example.GetN方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main()
{
Example e = new Example(1, 2.5); // use constructor
// this creates the first Example object with reference e
Console.WriteLine("e.n = {0}", e.GetN()); // prints 1
Console.WriteLine("e.d = {0}", e.GetD()); // prints 2.5
Console.WriteLine(e); // prints Example: n = 1, d = 2.5
e.SetN(25);
e.SetD(3.14159);
Console.WriteLine("e.n = {0}", e.GetN()); // prints 25
Console.WriteLine("e.d = {0}", e.GetD()); // prints 3.14159
Console.WriteLine(e); // prints Example: n = 25, d = 3.14159
Example e2 = new Example(3, 10.5);
// this creates the second Example object with reference e2
Console.WriteLine(e2); // prints Example: n = 3, d = 10.5
e = e2; // now both e and e2 reference the second object
// the first Example object is now no longer referenced
// and its memory can be reclaimed at runtime if necessary
Console.WriteLine(e); // prints Example: n = 3, d = 10.5
e2.SetN(77); // symbolism uses e2, not e
Console.WriteLine(e2); // prints Example: n = 77, d = 0
Console.WriteLine(e); // prints Example: n = 77, d = 0
// but e is the same object - so its fields are changed
}