摘要:
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. 阅读全文
摘要:
//获取程序集的特性方法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 阅读全文
摘要:
//内部定义类使用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 阅读全文
摘要:
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 阅读全文