本文整理汇总了C#中System.TestClass.AddOptional方法的典型用法代码示例。如果您正苦于以下问题:C# TestClass.AddOptional方法的具体用法?C# TestClass.AddOptional怎么用?C# TestClass.AddOptional使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.TestClass
的用法示例。
在下文中一共展示了TestClass.AddOptional方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
private static void Main(string[] args)
{
var testClass = new TestClass("TestInstance");
Console.WriteLine("Test of integer param to a method. Expected value: 5 Return Value:" + testClass.Add(2, 3));
Console.WriteLine("Test of double param to a method. Expected value: 4 Return Value:" + testClass.Subtract(6, 2));
Console.WriteLine("Test of return value of a method. Expected value: TestInstance Return Value:" + testClass.GetName());
Console.WriteLine("Test of generic parameters to a method. Expected value: TestClass Return Value:" + testClass.GetTypeName<TestClass>());
Console.WriteLine("Test of generic parameters to a method. Expected value: TestClass Return Value:" + testClass.GetTypeName<TestClass>(testClass));
string name = "Punit", name2 = string.Empty;
Console.WriteLine("Test of ref parameters to a method. Expected value: Punit.appended Return Value:" + testClass.GetRefValue(ref name));
Console.WriteLine("Value of name (ref)" + name);
Console.WriteLine("Test of out parameters to a method. Expected value: new Value Return Value:" + testClass.GetOutValue(out name2));
Console.WriteLine("Value of name (out)" + name2);
Console.WriteLine("Test of static method. Expected value: NewInstance Return Value:" + TestClass.Create().Name);
Console.WriteLine("Test of array as parameter to a method. Expected value: 2 Return Value:" + testClass.GetArrayCount(new[] { "new1", "new2" }));
Console.WriteLine("Test of optional parameter to a method. Expected value: 8 Return Value:" + testClass.AddOptional(3));
Console.WriteLine("Test of optional parameter to a method. Expected value: 10 Return Value:" + testClass.AddOptional(3, 7));
Console.WriteLine("Test call of delegate");
TestClass.MyDelegate delegateDefinition = new TestClass.MyDelegate(DelegateCalled);
testClass.CallDelegate(delegateDefinition);
Console.WriteLine("Name is: " + testClass.NameProperty);
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}