日期:2014-05-18 浏览次数:21437 次
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace 结构 { struct IDCard { public int id; public string name; public int Id { get { return id; } set { id = value; } } public string Name { get { return name; } set { name = value; } } } class Program { static void Main(string[] args) { IDCard idc; idc.id = 12345; //直接对字段赋值 idc.name = "张四 "; //直接对字段赋值 Console.WriteLine("身份证号码:{0},姓名:{1}",idc .Id ,idc .Name ); Console.ReadKey(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace 结构 { struct IDCard { public int id; public string name; public int Id { get { return id; } set { id = value; } } public string Name { get { return name; } set { name = value; } } } class Program { static void Main(string[] args) { IDCard idc; [u]idc.Id = 12345;[/u] //直接对属性赋值 idc.Name = "张四 "; //直接对属性赋值 Console.WriteLine("身份证号码:{0},姓名:{1}",idc .Id ,idc .Name ); Console.ReadKey(); } } }