2014.8.29结构体.函数

(一)结构体

        

然后在main函数里就可以定义:

 1 static void Main(string[] args)
 2 {
 3     Student stu = new Student();
 4     stu.name = "张三";
 5     stu.NO = 20140813;
 6     stu.age = 24;
 7 
 8     Console.WriteLine("我叫{0},今年{1}岁,我的学号是{2}",stu.name,stu.age,stu.NO);
 9     Console.ReadKey();
10 }

(二)函数

函数的四要素:函数名,输入,返回值,函数体

 1 static void Main(string[] args)
 2 {
 3     int x = 3, y = 5;
 4     Console.WriteLine("最大值是{0}",Max(x,y));//调用时括号里面的为实参
 5     Console.ReadKey();
 6 }
 7 static int Max(int a, int b)//括号里面的为形参
 8 {
 9     if (a > b)
10     {
11     return a;
12     }
13     else
14     {
15     return b;
16     }
17 }

原文地址:https://www.cnblogs.com/zsmj001/p/3945608.html