posts - 261,comments - 48,views - 91万
12 2015 档案
C# 特性 Attribute
摘要:特性就是在类的类名称、属性、方法等上面加一个标记,使这些类、属性、方法等具有某些统一的特征,从而达到某些特殊的需要。举个小栗子:方法的异常捕捉,你是否还在某些可能出现异常的地方(例如数据库的操作、文件的操作等)经常使用try...catch。这个时候如果使用特性,就可 以大大减少方法里面的try... 阅读全文
posted @ 2015-12-05 21:17 miaoying 阅读(1050) 评论(0) 推荐(0) 编辑
关键字 new 的作用
摘要:①做运算符用于创建对象和调用构造函数,小栗子a如下:Class1 obj = new Class1();创建匿名类型的实例,小栗子b如下:var query = from cust in customers select new {Name = cust.Name, Addr... 阅读全文
posted @ 2015-12-05 14:41 miaoying 阅读(5367) 评论(1) 推荐(0) 编辑
关键字 base 的作用
摘要:①调用基类上已被其他方法重写的方法,小栗子a如下: public class Father { public virtual void Show() { Console.WriteLine(" I am ... 阅读全文
posted @ 2015-12-05 13:17 miaoying 阅读(709) 评论(0) 推荐(0) 编辑
关键字 this 的作用
摘要:1.关键字 this①是指当前对象自己当一个类中要明确指出使用对象自己的变量或函数时,就应该加上this关键字,小栗子a如下: public class A { string Name = "我是一号~~"; public A(string... 阅读全文
posted @ 2015-12-04 20:20 miaoying 阅读(693) 评论(0) 推荐(0) 编辑
random类的使用
摘要:小栗子a如下:string[] punch = new[] { "石头", "剪刀", "布" };string myPunch;public string MyPunch { get { Random random = new Random(... 阅读全文
posted @ 2015-12-04 13:03 miaoying 阅读(179) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示