# C_sharp.net学习
**Repository Path**: litter_hui/c-sharpnet-learning
## Basic Information
- **Project Name**: C_sharp.net学习
- **Description**: 学习C#.net的记录
- **Primary Language**: C#
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2021-09-01
- **Last Updated**: 2021-11-26
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# C#
[TOC]
### 创建一个win应用

这个form.cs是win的主体,可以(查看源代码)手动写代码,也可以单击拉控件。
```c#
private void Form1_Load(object sender, EventArgs e)
{
this.Text = "这是我的第一个Win程序";
Label lblShow = new Label();
lblShow.Location = new Point(50, 30);
lblShow.AutoSize = true;
lblShow.Text = "本程序由Litter hui设计";
this.Controls.Add(lblShow);
}
```
### 控件设置

```c#
private void btnOK_Click(object sender, EventArgs e) //按键事件
{
string strResult;
strResult = textBox1.Text + ",你好!欢迎使用本程序!";
labelshow.Text = strResult;
}
```
不同的控件有不同的属性,属性里面的每个信息,都可以在.cs文件中调用,但是前后的信息要一样,调用时要像类一样去使用。
### WEB组件
```c#
public partial class text : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.Title = "实例1-4";
Label lblShow = new Label();
lblShow.Text = "这是我的第一个Web版的C#程序。
";
lblShow.Text +="请记住,C#的最大特色是它统一了各种应用程序的开发模式。
";
lblShow.Text += "若需帮助,请与作者胡明辉联系。";
lblShow.Font.Size = FontUnit.Point(16);
this.Controls.Add(lblShow);
}
}
```
HTML标记
```
换行
加粗文字
显示超链接
```
### 变量

变量的使用个C语言差别不大,按照C语言的格式去写就行。
### 结构体
结构体的使用和C语言一样,只不过它内置有一些特定的结构体

```c#
struct Student
{
public int id;
public string name;
public int age;
public char sex;
}
private void Form1_Load(object sender, EventArgs e)
{
Student a;
a.id = 0001;
a.name = "小辉";
a.age = 20;
a.sex = '男';
labelshow.Text = "student information\nname:" + a.name;
labelshow.Text += "\nID:" + a.id;
labelshow.Text += "\nSex:" + a.sex;
labelshow.Text += "\nage:" + a.age;
}
```
### 变量转化
