当前位置: 首页>>代码示例>>C#>>正文


C# BaseClass.F2方法代码示例

本文整理汇总了C#中BaseClass.F2方法的典型用法代码示例。如果您正苦于以下问题:C# BaseClass.F2方法的具体用法?C# BaseClass.F2怎么用?C# BaseClass.F2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BaseClass的用法示例。


在下文中一共展示了BaseClass.F2方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

    public static void Main() {

        BaseClass obj1=new BaseClass();
        CheckReturnedInt(obj1.F1("obj1"), 1);
        CheckReturnedString(obj1.F2("obj1"), "String returned from BaseClass.F2:obj1");
        CheckReturnedString(obj1.NonVirtualFunc(11), "String returned from BaseClass.NonVirtualFunc:11");
        Console.WriteLine("");

        DerivedClass obj2=new DerivedClass();
        CheckReturnedInt(obj2.F1("obj2"), 2);
        CheckReturnedString(obj2.F2("obj2"), "String returned from DerivedClass.F2:obj2");
        CheckReturnedString(obj2.NonVirtualFunc(15), "String returned from DerivedClass.NonVirtualFunc:30");
        Console.WriteLine("");

        BaseClass objectRef;
        objectRef = obj1;
        CheckReturnedInt(objectRef.F1("objectRef is now obj1"), 1);
        CheckReturnedString(objectRef.F2("objectRef is now obj1"), "String returned from BaseClass.F2:objectRef is now obj1");
        CheckReturnedString(objectRef.NonVirtualFunc(11), "String returned from BaseClass.NonVirtualFunc:11");
        Console.WriteLine("");

        objectRef = obj2;
        CheckReturnedInt(objectRef.F1("objectRef is now obj2"), 2);
        CheckReturnedString(objectRef.F2("objectRef is now obj2"), "String returned from DerivedClass.F2:objectRef is now obj2");
        CheckReturnedString(objectRef.NonVirtualFunc(15), "String returned from BaseClass.NonVirtualFunc:15");
        Console.WriteLine("");

        if (failed) {
             System.Environment.ExitCode = 1;
        }
        else {
             System.Environment.ExitCode = 0;
        }
        
    }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:35,代码来源:baseclass_dispatch.cs


注:本文中的BaseClass.F2方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。