摘要: 假设有2个类,一个类是主力球员,一个类是替补球员。 public class NormalPlayer { public int ID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public de... 阅读全文
posted @ 2014-08-12 22:13 Darren Ji 阅读(2912) 评论(0) 推荐(0)
摘要: int类型的最大值是2147483647,2个最大值相加就会超出int的最大值,即出现溢出。 class Program { static void Main(string[] args) { int y = 2147483647; int x = 2147483647; int z = x... 阅读全文
posted @ 2014-08-12 17:13 Darren Ji 阅读(1110) 评论(1) 推荐(0)
摘要: 当对2个数实现加减乘除,其中的一个解决方案是通过委托来实现。如下: class Program { private delegate int CaculateDel(int num1, int num2); static void Main(string[] args) { CaculateDel caculateDel ... 阅读全文
posted @ 2014-08-12 16:36 Darren Ji 阅读(264) 评论(0) 推荐(0)
摘要: Convert.ToString能处理字符串为null的情况。 static void Main(string[] args) { string msg = null; Console.WriteLine(Convert.ToString(msg)); Console.ReadKey(); ... 阅读全文
posted @ 2014-08-12 15:57 Darren Ji 阅读(614) 评论(0) 推荐(0)
摘要: 本篇体验私有构造函数的特点,以及在何种情况下使用私有构造函数。 □ 带私有构造函数的类不能被继承 在Animal类中声明一个私有构造函数,让Dog类来继承Animal类。 public class Animal { private Animal() { Console.WriteLine("i am animal"); ... 阅读全文
posted @ 2014-08-12 15:39 Darren Ji 阅读(1327) 评论(0) 推荐(0)
摘要: 在Visual Studio中,生成应用程序的时候有2种模式:Debug和Release。两者之间如何取舍呢? 假设有这么简单的一段代码,在主程序中调用方法M1,M1方法调用M2方法,M2方法调用M3方法,M3方法中抛出异常。 class Program { static void Main(string[] args) { M1();... 阅读全文
posted @ 2014-08-12 12:11 Darren Ji 阅读(2858) 评论(0) 推荐(1)

我的公众号:新语新世界,欢迎关注。