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