struct结构

结构可以储存多个数据元素或函数等,可以集中处理常见任务

例要输出姓名:

 1 struct UserName
 2 {
 3     public string firstName;
 4     public string lastName;
 5     public string Name()
 6     {
 7         string name = firstName + lastName;
 8         return name;
 9     }
10 }
11 
12 static void Main(string[] args)
13 {
14     UserName user01;
15     user01.firstName = "TT";
16     user01.lastName = "6b";
17     Console.WriteLine(user01.Name());
18     Console.ReadKey();
19 }

 

posted @ 2018-11-02 23:30  邢韬  阅读(146)  评论(0编辑  收藏  举报