2013年2月27日

C#:结构

摘要: namespace ConsoleApplication8{public struct Dimensions{public double Height;public double Width;public Dimensions(double height, double width){Height = height;Width = width;}public double Diagonal{get{return Math.Sqrt(Height * Height + Width * Width);}}static void Main(string[] args){Dimensions test 阅读全文

posted @ 2013-02-27 17:51 LilianChen 阅读(1009) 评论(0) 推荐(1) 编辑

C#:属性

摘要: public string SomeProperty{// get 访问器不带参数,且必须返回属性声明的类型get{return"This is the property value";}// set访问器也不带任何显示参数,但是编译器假定它带一个参数,其类型也与属性相同,并表示为valueset{// do whatever needs to be done to set the property}}privatestring foreName;publicstring ForeName{get{return foreName;}set{if (value.Length 阅读全文

posted @ 2013-02-27 12:20 LilianChen 阅读(490) 评论(0) 推荐(1) 编辑

导航