C#程序题运行结果题.docVIP

  • 7
  • 0
  • 约1.44万字
  • 约 21页
  • 2020-03-29 发布于河北
  • 举报
三 写出运行结果题 (1) using System; class Program { static void Main() { int x = 3; Console.Write(星期:); Console.WriteLine((Weekday)x); Console.Write(月份:); Console.WriteLine((Month)x); Console.Write(季节:); Console.WriteLine((Season)x); } enum Weekday { 未知 = -1, 星期天, 星期一, 星期二, 星期三, 星期四,星期五,星期六 } enum Month { 一月, 二月, 三月, 四月, 五月, 六月, 七月, 八月, 九月, 十月, 十一月, 十二月, 未知 = -1 星期: 星期三 星期: 星期三 月份: 四月 季节:3 enum Season { 春, 夏 = 2, 秋 = 4, 冬 = 8 } } (2) using System; class Program { static void Main() { class1 c1 = new class1 class1.y = 5; c1.Output(); class1 c2 = new class1 c2.Output(); } } public class class1 05 0 5 0 0 5 5 private static int x = 0; public static int y = x; public int z = y; public void Output() { Console.WriteLine(class1.x); Console.WriteLine(class1.y); Console.WriteLine(z); } } (3) using System; class Program { static void Main() { IA ia = new B(); Console.WriteLine({0} {1} {2} {4}, ia is IA, ia is IB, ia is A, ia is A, ia is B, ia is C); } } public interface IA { } public interface IB : IA { } True True False Truepublic class A : IA { } True True False True public class B : IB { } public class C : B, IB { } (4) using System; class Program { static void Main(string[] args) { MyClass y = new MyClass(); BaseClass x = y; x.i = 100; Console.WriteLine({0}, {1}, x.i, y.i); } } class BaseClass { public int i; } 100,0class MyClass : BaseClass 100,0 { public new int i; } (5) using System; class Program { static void Main(string[] args) { MyClass x = new MyClass(); x.testParams(0); x.testParams(0, 1); x.testParams(0, 1, 2); } } class MyClass { public void testParams(params int[] arr) { Console.Write(使用Params参数!); } p

文档评论(0)

1亿VIP精品文档

相关文档