登录
  • 欢迎访问 Sharezer Blog

标签:C#

C#

【C#笔记】接口 (interface)

接口 (interface) 定义了一个可由类和结构实现的协定。接口可以包含方法、属性、事件和索引器。接口 不提供它所定义的成员的实现 — 它仅指定实现该接口的类或结构必须提供的成员。 接口可支持多重继承。在下面的示例中,接口 IComboBox 同时从 ITextBox 和 IListBox 继承。 interface IControl {     void Paint(); } interface ITextBox: IControl {     void SetText(string……继续阅读 »

sharezer 8年前 (2016-06-13) 1904浏览 0评论 0个赞

C#

【C#笔记】值类型 (value type) 和引用类型 (reference type)

C# 中的类型有两种:值类型 (value type) 和引用类型 (reference type)。值类型的变量直接包含它们的数据,而引用类型的变量存储对它们的数据的引用,后者称为对象。对于引用类型,两个变量可能引用同一个对象,因此对一个变量的操作可能影响另一个变量所引用的对象。对于值类型,每个变量都有它们自己的数据副本(除 ref 和 out 参数变量外),因此对一个变量的操作不可能影响另一个变量。 C# 的值类型进一步划分为简单类型 (simple type)、枚举类型 (enum type)、结构类型 (struct type) 和可以为 null 的类型 (nullable ty……继续阅读 »

sharezer 8年前 (2016-06-12) 2458浏览 0评论 0个赞

C#

AttributeTargets 枚举

指定可以对它们应用特性的应用程序元素 成员名称 说明 All 可以对任何应用程序元素应用属性。 Assembly 可以对程序集应用属性。 Class 可以对类应用属性。 Constructor 可以对构造函数应用属性。 Delegate ……继续阅读 »

sharezer 8年前 (2016-05-27) 1810浏览 0评论 0个赞

C#

C#秒转时间timeStampToString

public static string timeStampToString(int time) { long ltime = (long )time; DateTime t = new DateTime(time * TimeSpan.TicksPerSecond); t = t. ToLocalTime(); int year = t.Year + 1969 ; string syear = "" + year; int month = t.Month ; string smonth = month < 10……继续阅读 »

sharezer 8年前 (2016-04-27) 2016浏览 0评论 0个赞