admin管理员组

文章数量:1534832

2024年4月3日发(作者:)

第一章 实例:windows 应用程序

using System;

using c;

using entModel;

using ;

using g;

using ;

using ;

namespace test1

{

public partial class Form1 : Form

{

private int flag;

public Form1()

{

InitializeComponent();

flag = 1;

= "C#";

}

private void button1_Click(object sender, EventArgs e)

{

if (flag == 1)

{

= "hello";

flag = 0;

}

else

{

= "C#";

flag = 1;

}

}

}

}

控制台程序:

using System;

using c;

using ;

namespace test2

{

class Program

{

static void Main(string[] args)

{

ine("hello C#");

}

}

}

【实例2-1】

using System;

using ;

namespace TestEnum

{

public partial class TestEnum : Form

{

//Visual Studio .Net自动生成的构造函数,后文示例将全部省略

public TestEnum()

{

InitializeComponent();

}

enum MyEnum { a = 101, b, c, d = 201, e, f }; //声明枚举型

private void TestEnum_Load(object sender, EventArgs e)

{

MyEnum x = MyEnum.f; //使用枚举型

MyEnum y = (MyEnum)202;

string result ="枚举数x的值为";

result += (int)x; //将x转换为整数

result += "n枚举数y代表枚举元素" + y;

= result;

本文标签: 示例应用程序程序自动转换