public class Parent { void printMe() { System.out.println("parent"); } } class Child extends Parent { void printMe() { System.out.println("child"); } void printAll() { super.printMe(); this.printMe(); } } public class Examae { public static void main(String args[]) { (new Child()).printAll(); System.out.println("grandson"); } }转换为C#
时间: 2023-12-10 08:38:26 浏览: 64
PrintMe:一个简单的js文件打印库——打印特定区域,同时隐藏其他打印区域
以下是转换后的 C# 代码:
```
using System;
public class Parent
{
public virtual void PrintMe()
{
Console.WriteLine("parent");
}
}
public class Child : Parent
{
public override void PrintMe()
{
Console.WriteLine("child");
}
public void PrintAll()
{
base.PrintMe();
this.PrintMe();
}
}
public class Example
{
public static void Main()
{
(new Child()).PrintAll();
Console.WriteLine("grandson");
}
}
```
阅读全文