10 2009 档案

摘要:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace WindowsFormsAp... 阅读全文

posted @ 2009-10-27 11:27 Relax Active 阅读(370) 评论(0) 推荐(0) |

摘要:说明:Stack(堆栈)作为一种集合类型,适合于处理应用程序使用完后就删除的临时数据项。Queue(队列)与Stack用法相似,唯一的区别是Queue以先进先出的结构创建集合。Stack用法示例:using System;using System.Collections;using System.Collections.Generic;using System.Text;namespace Sta... 阅读全文

posted @ 2009-10-15 17:33 Relax Active 阅读(445) 评论(0) 推荐(0) |

摘要:说明:数组列表用法类似于数组,但数组列表可以增大,它由System.Collections.ArrayList来表示。using System;using System.Collections;using System.Collections.Generic;using System.Text;namespace ArrayList3{ class Program { static void Ma... 阅读全文

posted @ 2009-10-15 14:56 Relax Active 阅读(190) 评论(0) 推荐(1) |

摘要:Cub.cs代码:using System;using System.Collections.Generic;using System.Collections;using System.Text;namespace ConsoleApplication1{ public class Cub : IEnumerable //声明立方体Cub类继承IEnumerable接口! { int length... 阅读全文

posted @ 2009-10-12 15:35 Relax Active 阅读(277) 评论(1) 推荐(1) |

摘要:可空类型(C# 编程指南)可空类型是 System.Nullable 结构的实例。可空类型可以表示其基础值类型正常范围内的值,再加上一个 null 值。例如,Nullable<Int32>,读作“可空的 Int32”,可以被赋值为 -2147483648 到 2147483647 之间的任意值,也可以被赋值为 null 值。Nullable<bool>... 阅读全文

posted @ 2009-10-10 15:02 Relax Active 阅读(166) 评论(0) 推荐(0) |

摘要:说明:is关键字用来检查对象是否与给定类型兼容。例如,以下代码可以确定对象是否与 string 类型兼容: 复制代码 if (obj is string){}备注如果所提供的表达式非空,并且所提供的对象可以强制转换为所提供的类型而不会导致引发异常,则 is 表达式的计算结果将是 true。如果已知表达式将始终是 true 或始终是 false,则 is 关键字将导致编译时警告,但是,通常在运行时才... 阅读全文

posted @ 2009-10-10 14:56 Relax Active 阅读(131) 评论(0) 推荐(0) |

摘要:checked 关键字用于对整型算术运算和转换显式启用溢出检查。默认情况下,如果表达式产生的值超出了目标类型的范围,则常数表达式将导致编译时错误,而非常数表达式在运行时计算并将引发异常。不过,如果通过编译器选项或环境配置在全局范围内取消了溢出检查,则可以使用 checked 关键字来启用此项功能。请参见有关 unchecked 关键字用法的 unchecked 示例。 示例 此示例演示如何对非常数... 阅读全文

posted @ 2009-10-10 14:53 Relax Active 阅读(187) 评论(0) 推荐(0) |

摘要:说明:接口的实现方式分显示实现和隐示实现。目前常用的方式:public interface IReview{ void GetReviews();}public class ShopReview :IReview{ public void GetReviews(){}}这种方式是隐示实现: IReview rv = new ShopReview();rv.GetReviews(); ShopRev... 阅读全文

posted @ 2009-10-10 14:33 Relax Active 阅读(159) 评论(0) 推荐(0) |

摘要:sealed 修饰符可以应用于类、实例方法和属性。密封类不能被继承。密封方法会重写基类中的方法,但其本身不能在任何派生类中进一步重写。当应用于方法或属性时,sealed 修饰符必须始终与 override(C# 参考) 一起使用。在类声明中使用 sealed 修饰符可防止继承此类,例如:[代码]将密封类用作基类或将 abstract 修饰符与密封类一起使用是错误的。结构是隐式密封的;因此它们不能被... 阅读全文

posted @ 2009-10-10 14:21 Relax Active 阅读(178) 评论(0) 推荐(0) |

摘要:说明:类的合法成员有字段、属性、方法和事件。 阅读全文

posted @ 2009-10-10 10:36 Relax Active 阅读(107) 评论(0) 推荐(0) |

摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication4{ public class A { public virtual string Function() //声明一个虚方法,可以被重写! { return "1"; } } pu... 阅读全文

posted @ 2009-10-10 10:21 Relax Active 阅读(139) 评论(0) 推荐(0) |

摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace Interface{ class Program { public interface Ifire { void fire(); void yongbao(); } public class Tank : Ifir... 阅读全文

posted @ 2009-10-09 15:16 Relax Active 阅读(203) 评论(0) 推荐(0) |

摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace juchen3{ abstract class Shape //声明一个基类Shape! { public const double pi = System.Math.PI; //声明基类成员变量! protecte... 阅读全文

posted @ 2009-10-09 10:43 Relax Active 阅读(470) 评论(0) 推荐(0) |

摘要:public(C#参考)public 关键字是类型和类型成员的访问修饰符。公共访问是允许的最高访问级别。对访问公共成员没有限制,如下例所示:class SampleClass{ public int x; // No access restrictions.} 示例 在下面的示例中,声明了两个类:Point 和 MainClass。直接从 MainClass 访问 Point 的公共成员 x 和 ... 阅读全文

posted @ 2009-10-08 14:23 Relax Active 阅读(634) 评论(0) 推荐(0) |

摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace Demo10{ public class FatherClass //声明一个基类! { public virtual decimal Caculate() //声明一个有返回值的方法! { return 10M; ... 阅读全文

posted @ 2009-10-08 14:20 Relax Active 阅读(295) 评论(0) 推荐(0) |

摘要:Animal的虚方法场景示例://Animal.csusing System;using System.Collections.Generic;using System.Linq;using System.Text;namespace Inherit{ public class Animal //声明一个Animal类! { public virtual void bite() //用关键字vir... 阅读全文

posted @ 2009-10-08 14:19 Relax Active 阅读(115) 评论(0) 推荐(0) |

摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace Inherit{ class Program { public interface Animal //声明一个Animal接口! { void bite(); //声明接口的方法成员! } public class ... 阅读全文

posted @ 2009-10-08 14:18 Relax Active 阅读(124) 评论(0) 推荐(0) |

博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3