當前位置: 首頁>>代碼示例>>C#>>正文


C# TestClass.Subtract方法代碼示例

本文整理匯總了C#中System.TestClass.Subtract方法的典型用法代碼示例。如果您正苦於以下問題:C# TestClass.Subtract方法的具體用法?C# TestClass.Subtract怎麽用?C# TestClass.Subtract使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.TestClass的用法示例。


在下文中一共展示了TestClass.Subtract方法的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();
        }
開發者ID:hermanocabral,項目名稱:CodeInject,代碼行數:34,代碼來源:Program.cs


注:本文中的System.TestClass.Subtract方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。