摘要: 先发案例代码,尾部分析:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace _2011._12._23{ class Sum_Int { private int x; public int X { get { return x; } set { x = value; } } public Sum_Int(int i) { ... 阅读全文
posted @ 2011-12-23 09:37 Anleb 阅读(843) 评论(0) 推荐(0) 编辑
摘要: 经典案例案例1:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{ abstract class Test1 { public int Num1 { get; private set; } public int Num2 { get; private set; } public Test1(int num1,int num2) { N... 阅读全文
posted @ 2011-12-22 11:32 Anleb 阅读(1647) 评论(0) 推荐(0) 编辑
摘要: 说一句题外话,本人学C# 不到一个月时间,今天同事说了2个 区别 抽象类与区别,我感觉请教前辈 超过自己的看10个小时的理解。抽象类abstract抽象方法的类要声明为抽象类构造函数和静态方法不能声明为抽象多态性是一个虚方法,可以重写这个方法,实现同一个方法不同的表现形式对于抽象方法的重写,是说的对于这个方法的派生类的实现。对于抽象类和接口的方法都需要实现。抽象方法是无法写方法体的抽象类可以写 实现的方法接口不可以写 实现的方法案例1:using System;using System.Collections.Generic;using System.Linq;using System.Tex 阅读全文
posted @ 2011-12-21 18:54 Anleb 阅读(2842) 评论(9) 推荐(4) 编辑
摘要: 案例1:<原始的方法>static void Main(string[] args) { //委托的比较 //常规方式 int[] numbers = { 1,2,3,4,5,6,7,8,9,10}; List<int> evenNumber = new List<int>();//偶数 List<int> oddNumber = new List<int>();//奇数 List<int> over5Number = new List<int>()... 阅读全文
posted @ 2011-12-20 14:36 Anleb 阅读(690) 评论(0) 推荐(0) 编辑
摘要: 先说原始的构造函数:案例1:<类的重载构造函数>class Program { static void Main(string[] args) { Person oneperson1 = new Person(15,"jack",160.00);//调用第一个构造函数 Console.WriteLine(oneperson1);//这里隐式ToString()方法 Person oneperson2 = new Person("jack", 15,160.00);//调用第二个构造函数 ... 阅读全文
posted @ 2011-12-19 16:04 Anleb 阅读(2370) 评论(3) 推荐(0) 编辑
摘要: 案例3:<案例分析>namespace _2011._12._19{ class Program { static void Main(string[] args) { Box box = new Box(10, 20, 30); Display(box[0],box[1],box[2]); Console.WriteLine(box["High"]); ... 阅读全文
posted @ 2011-12-19 13:51 Anleb 阅读(657) 评论(5) 推荐(1) 编辑
摘要: LINQ-TO-SQL:案例1:基础模型static void Main(string[] args) { int[] int_array = { 1, 8, 5, 9, 15, 20 }; var filtered = from value in int_array//注意是var,可以帮助我们减少很多麻烦 where value > 4 select value; Console.WriteLine(filtered.G... 阅读全文
posted @ 2011-12-16 16:58 Anleb 阅读(985) 评论(0) 推荐(1) 编辑
摘要: 数组的初始化 错误案例:1.int[] array; array[10]=5; //错误2.int[] array=new int[5]{1,2,3};//错误正确案例:1.int[] array=new int[5];2.int[] array={1,2,3,4,5};3.static void Main(string[] args) { // int arraysize = 5; 错误 const int arraysize = 5; int[] array = new int[arraysize] { 1, 2... 阅读全文
posted @ 2011-12-16 12:18 Anleb 阅读(662) 评论(3) 推荐(2) 编辑
摘要: 储存数组其实不是对象,而是对象的引用地址(储存对象的计算机的内存地址)值类型,当方法调用的时候,因为传递进 方法的值只是原变量的一个副本,所以改变了副本不会改变原变量。引用类型,当方法调用的时候,因为传递进方法的也是一个副本,只不过是 引用的副本,这个引用的副本也是指向 原对象的,所以修改了引用副本就会影响到对象。如果结合这个案例,彻底把这个过程分析清楚:分析案例:class Program { static void Main(string[] args) { int[] ints = { 1, 2, 3 }; i... 阅读全文
posted @ 2011-12-15 23:53 Anleb 阅读(1906) 评论(2) 推荐(2) 编辑
摘要: GetType()与Typeof()区别GetType()返回的是对象的类名案例1:int i = 5;Console.WriteLine(i.GetType());//System.Int32var x = 127.25m;Console.WriteLine(x.GetType());//System.Decimal案例2:namespace _2011._12._15{ class Program { static void Main(string[] args) { Test testone = new Test(); ... 阅读全文
posted @ 2011-12-15 15:40 Anleb 阅读(1865) 评论(0) 推荐(1) 编辑