摘要: classProgram{staticvoidMain(string[]args){intnum=10;num.SayGoodNews();//输出hehestringresult=num.GetSomeString(100,50);Console.Write(result);//输出150Console.Read();}} staticclassIntExtension//注意为某个类中添加扩展方法,必须是静态类{publicstaticvoidSayGoodNews(thisintx)//不带参数的扩展方法使用{Console.Write(x);} publicstaticstringG. 阅读全文
posted @ 2013-04-11 20:03 Predator 阅读(200) 评论(0) 推荐(0) 编辑
摘要: //获取程序集的特性方法public string AssemblyTitle{get{object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);if(attributes.Length > 0){AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];if(titleAttribute.Title != "&qu 阅读全文
posted @ 2013-04-11 19:18 Predator 阅读(366) 评论(0) 推荐(0) 编辑
摘要: //内部定义类使用using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConTest{ class Cow { private string name; public class Chicken { private int foots; public int Foots { get { return foots; } set { foots = value; } } private string name; public string Name { get { r 阅读全文
posted @ 2013-04-11 19:17 Predator 阅读(249) 评论(0) 推荐(0) 编辑
摘要: System.Threading.Thread.Sleep(2000); Console.WriteLine("Has Conme"); long start = DateTime.Now.Ticks; long end = DateTime.Now.Ticks; long span = end - start; while (true) { if (span>=20000000)//等于2秒的时候输出 { Console.WriteLine("Has Conme"); break; } end = DateTime.Now.Ticks; span 阅读全文
posted @ 2013-04-11 19:15 Predator 阅读(284) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Collections;using System.Windows.Forms;namespace testset{ /// <summary> /// 对ListView点击列标题自动排序功能 /// </summary> public class ListViewHelper { /// <summary> /// 构造函数 /// </summary> p 阅读全文
posted @ 2013-04-11 19:07 Predator 阅读(584) 评论(0) 推荐(0) 编辑
摘要: usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text; namespaceConTest{classObjectOperation{publicstaticvoidChangeProperty(Students){s.Name="Iam";s.Age=23;}publicstaticvoidMain(){Students=newStudent(23,"甘全福");ChangeProperty(s);s.DisplayInfo();//输出Name:Iam 阅读全文
posted @ 2013-04-11 07:47 Predator 阅读(300) 评论(0) 推荐(0) 编辑