摘要: (1)string是引用类型:string是引用类型,这就是说string在堆上保存数据,而在栈中存储的是对象地址,在理解string类型特性时首先需要记住这点。只不过与其它一些引用类型相比,它又有一些比较特殊的特性,比如下面的这些:(2)string是不可变的(immutable):string的这一特性是指,对于已有的一个string对象,当你修改它时,实际是重新创建了一个符合你要求的string对象。我通过以下的例子进行演示:staticvoidMain(string[] args){stringx ="should it matter"; x = x +" 阅读全文
posted @ 2013-07-17 20:50 墓地de小草 阅读(210) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.IO;namespace _05标志枚举{ class Program { static void Main(string[] args) { //FileInfo info = new FileInfo(@"c:\hello.txt"); //Console.WriteLine(info.Attributes); ... 阅读全文
posted @ 2013-07-17 20:28 墓地de小草 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace _09new关键字用来隐藏父类方法 7 { 8 class Program 9 {10 static void Main(string[] args)11 {12 ////Person p = new Chinese();13 ////p.SayHi();14 ... 阅读全文
posted @ 2013-07-17 20:14 墓地de小草 阅读(336) 评论(0) 推荐(0) 编辑
摘要: 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace _16静态成员静态类 7 { 8 class Program 9 {10 static void Main(string[] args)11 {12 13 14 //MyClass mc = new MyClass();15 //mc.... 阅读全文
posted @ 2013-07-17 19:51 墓地de小草 阅读(250) 评论(0) 推荐(0) 编辑
摘要: 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace _14用虚方法实现多态 7 { 8 public class Person 9 {10 public Person(string name)11 {12 this.Name = name;13 }14 public string Name15 {16 ... 阅读全文
posted @ 2013-07-17 19:46 墓地de小草 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace _09访问修饰符 7 { 8 public class Class1 9 {10 //private私有访问修饰符,只能在当前类内部来访问。11 12 private int age;13 //protected访问修饰符,只能在当前类内部,以及所有当前类的子类的内部。14 protected st... 阅读全文
posted @ 2013-07-17 19:15 墓地de小草 阅读(207) 评论(0) 推荐(0) 编辑
摘要: //c#中任何一个类都是继承自object类的。//如果一个类没有显示继承自任何类,则默认继承自object类。//如果显示的指定了当前类继承自某个类,则将覆盖默认继承的object类。//===继承的传递性://SuperMan继承了object,这时,SuperMan类中就有了从object类中继承下来的4个方法ToString()、GetType()、GetHashCode()、Equals()。//然后Person又继承了SuperMan,这时,Person会将SuperMan中的那4个方法再继承下来。由于那4个方法是在object中的,所以相当于Person类间接从Object类中继 阅读全文
posted @ 2013-07-17 18:53 墓地de小草 阅读(197) 评论(0) 推荐(0) 编辑