- 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
您可能关注的文档
最近下载
- 5.XXXX金属科技有限公司安全设施设计---铝棒和铝杆生产线.doc
- 2026年度辽宁轨道交通职业学院单招《数学》高频难、易错点题及参考答案详解(能力提升).docx VIP
- 2024年国考行政执法行测答案及解析.pdf
- 2025年部编版五年级数学上册单元测试.docx VIP
- 水利工程设计概(估)算编制规定(水总[2014]429号).docx VIP
- 22j4031楼梯栏杆图集.pptx VIP
- 脑电图学专业知识测试题及答案.pdf VIP
- 2026年甘肃省酒泉市高三一模物理高考模拟试卷(含答案详解).pdf VIP
- 十几减9(课件)2025一年级数学下册人教版(2024).pptx
- 中国阿尔茨海默病痴呆诊疗指南(2025年版).docx
原创力文档

文档评论(0)