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;
版权声明:本文标题:c#源代码 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1712159682a346366.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论