结构体类型的运用

as86238582 2012-03-27 09:00:01
定义一个结构类型student,结构成员有学生的姓名,年龄、性别。然后在Main函数里定义一个student类型的变量,赋值,最后将这个学生姓名,年龄、性别输出。
...全文
55 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
laichunlin 2012-03-27
  • 打赏
  • 举报
回复
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();
}
}
}
种草德鲁伊 2012-03-27
  • 打赏
  • 举报
回复
看下楼主的其他提问。
as86238582 2012-03-27
  • 打赏
  • 举报
回复
还是不明白,专科的书,我根本看不懂.
觉悟之时 2012-03-27
  • 打赏
  • 举报
回复
把以前的class这个关键字换成strut,别的都不变就可以了。

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧