码迷,mamicode.com
首页 > 其他好文 > 详细

结构体20140827

时间:2014-08-27 16:11:17      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   ar   2014   div   log   sp   line   

  1. 结构体 定义自己的类型my tape
  2. 在main括号外面加public stuct **  **为自己的类型  下边加大括号  括号里是自己的类型里面包括的对象
  3. 在里边写 public +类型+变量名   类型里面可以加自己创建的类型 
  4. 把 中间的class 去掉,新添加的其他新建项也可以用 这个类型
public struct snakepoint
        {
            public int x;
            public int y;
        }
        static void Main(string[] args)
        {
            snakepoint s = new snakepoint();
            s.x = 5;
            s.y = 10;

            ArrayList a = new ArrayList();
            a.Add(s);


            Console.WriteLine((snakepoint )a[0].x+","+((snakepoint)a[0]).y);
        {
            student lch = new student();
            lch.no = 1;
            lch.name = "xxx";
            lch.Cshap = 90;
            lch.web = 78;
            lch.datebase = 83;
            lch.sum = lch.Cshap + lch.web + lch.datebase;
            Console.WriteLine(("学号·{0}姓名·{1}Cshap·{2}web·{3}datebase·{4}总分·{5}"), lch.no, lch.name, lch.Cshap, lch.web, lch.datebase, lch.sum);
        }
        
                
        struct student
        {
            public int no;
            public string name;
            public int Cshap;
            public int web;
            public int datebase;
            public int sum;
        }

 

  

结构体20140827

标签:style   blog   color   ar   2014   div   log   sp   line   

原文地址:http://www.cnblogs.com/jackjms/p/3939530.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!