标题:关于结构和类
取消只看楼主
yuanquan0104
Rank: 1
等 级:新手上路
帖 子:69
专家分:0
注 册:2005-7-8
 问题点数:0 回复次数:0 
关于结构和类
using System;
class  C1
{
 public string Name;
 public string ID;
 public string Name1;
 public int Age;
}
class C2
{
 public static void Main()
 {
  C1 c  = new C1();
  c.Name = "heng yi zi xun";
  c.ID = "001";
  c.Name1 = "wangqiang";
  c.Age = 20;
  Console.WriteLine(" gong si ming cheng{0}",c.Name);
  Console.WriteLine(" yuan gong dai ma{0}",c.ID);
  Console.WriteLine(" yuan gong ming cheng{0}",c.Name1);
  Console.WriteLine(" yuan gong nian ling{0}",c.Age);
 }
}

using System;
struct C1
{
 public string Name;
 public string ID;
 public string Name1;
 public int Age;
}
class C2
{
 public static void Main()
 {
  C1 c;
  c.Name = "heng yi zi xun";
  c.ID = "001";
  c.Name1 = "wang qiang ";
  c.Age = 20;
  Console.WriteLine(" gong si ming cheng{0}",c.Name);
  Console.WriteLine(" yuan gong dai ma{0}",c.ID);
  Console.WriteLine(" yuan gong ming cheng{0}",c.Name1);
  Console.WriteLine(" yuan gong nian ling{0}",c.Age);
 }
}

以上两个程序的区别在哪里,我看没有什么区别,好像是访问上的区别,请详细指点一下。谢谢
搜索更多相关主题的帖子: 结构 
2005-07-16 13:35



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-23020-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.373916 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved