定义一个结构类型student,结构成员有学生的姓名,年龄、性别。然后在Main函数里定义一个student类型的变量,赋值,最后将这个学生姓名,年龄、性别输出。

解决方案 »

  1.   

    把以前的class这个关键字换成strut,别的都不变就可以了。
      

  2.   

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;namespace ttt
    {
        struct student
        {
            public string sname;
            public int age;
            public string sex;
        }    class Program
        {
            static void Main(string[] args)
            {
                student st = new student();
                st.sname = "张三";
                st.age = 23;
                st.sex = "男";
                Console.WriteLine("姓名:"+st.sname+"\n");
                Console.WriteLine("年龄:"+st.age.ToString()+"\n");
                Console.WriteLine("性别:"+st.sex+"\n");
                Console.ReadLine();
            }
        }
    }