[随笔分类]C#基础
文章平均质量分 66
iteye_617
这个作者很懒,什么都没留下…
展开
-
C#拾遗系列(1):委托
一、委托概述 委托具有以下特点: 委托类似于 C++ 函数指针,但它们是类型安全的。 委托允许将方法作为参数进行传递。 委托可用于定义回调方法。 委托可以链接在一起;例如,可以对一个事件调用多个方法。 方法不必与委托签名完全匹配。(委托中的协变和逆变) ...2008-06-11 14:43:00 · 61 阅读 · 0 评论 -
C#拾遗系列(7):自定义属性
1 .描述 属性提供功能强大的方法以将声明信息与 C# 代码(类型、方法、属性等)相关联。属性与程序实体关联后,即可在运行时使用名为“反射”的技术查询属性。 属性以两种形式出现: 一种是在公共语言运行库 (CLR) 中定义的属性。 另一种是可以创建的用于向代码中添加附加信息的自定义属性。此信息可在以后以编程方式检索。 2. 示例代码: using System; using S...2008-06-18 14:52:00 · 79 阅读 · 0 评论 -
C#拾遗系列(7):自定义属性
1 .描述 属性提供功能强大的方法以将声明信息与 C# 代码(类型、方法、属性等)相关联。属性与程序实体关联后,即可在运行时使用名为“反射”的技术查询属性。 属性以两种形式出现: 一种是在公共语言运行库 (CLR) 中定义的属性。 另一种是可以创建的用于向代码中添加附加信息的自定义属性。此信息可在以后以编程方式检索。 2. 示例代码: using System; usi...2008-06-18 14:52:00 · 65 阅读 · 0 评论 -
C#拾遗系列(8):异常
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace NetTest { public class TestException { public void TestThrow() { ...2008-06-19 11:02:00 · 66 阅读 · 0 评论 -
C#拾遗系列(8):异常
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace NetTest { public class TestException { public void TestThrow() { ...2008-06-19 11:02:00 · 64 阅读 · 0 评论 -
C#拾遗系列(9):继承、接口、扩展方法、分部类、类操作、Ref and Out、可空类型...
本文内容: 继承 Equal示例 结构和类 属性 Ref and Out 类操作 扩展方法 接口 可空类型 分部类 1. 继承using System;using System.Collections.Generic;using System.Linq;using System.Text;names...2008-06-19 15:07:00 · 103 阅读 · 0 评论 -
C#拾遗系列(9):继承、接口、扩展方法、分部类、类操作、Ref and Out、可空类型...
本文内容:继承 Equal示例 结构和类 属性 Ref and Out 类操作 扩展方法 接口 可空类型 分部类 1. 继承using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace...2008-06-19 15:07:00 · 95 阅读 · 0 评论 -
MSIL(1): Hello World
1. 用记事本编写如下代码.assembly HelloWorld{}.assembly extern mscorlib{}.class HelloWorld extends [mscorlib]System.Object{ .method public static void HelloWorld() { .maxstack 1 ldstr "Hello Worl...2009-03-09 22:14:00 · 85 阅读 · 0 评论 -
代码段:ASCII to Unicode
1: private string ConvertAsciiToUnicode(string theAsciiString) 2: { 3: // Create two different encodings. 4: Encoding aAsciiEncoding = Encoding.ASCII; ...2009-04-17 10:44:00 · 137 阅读 · 0 评论 -
Get countries from system
1: using System; 2: using System.Collections.Generic; 3: using System.Linq; 4: using System.Text; 5: using System.Globalization; 6: using System.IO; 7: 8: namespace Culture...2009-05-08 16:02:00 · 121 阅读 · 0 评论 -
[Tips]:Read value from Resource file in C#
1: //Namespace reference 2: using System; 3: using System.Resources; 4: 5: 6: #region ReadResourceFile 7: /// <summary> 8: ...2009-05-18 16:18:00 · 173 阅读 · 0 评论 -
C#拾遗系列(6):迭代器
1. 示例:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Collections; namespace NetTest{ public class TestIteration { public void ...2008-06-14 23:03:00 · 63 阅读 · 0 评论 -
C#拾遗系列(6):迭代器
1. 示例:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Collections; namespace NetTest{ public class TestIteration { public void ...2008-06-14 23:03:00 · 73 阅读 · 0 评论 -
C#拾遗系列(1):委托
一、委托概述 委托具有以下特点: 委托类似于 C++ 函数指针,但它们是类型安全的。 委托允许将方法作为参数进行传递。 委托可用于定义回调方法。 委托可以链接在一起;例如,可以对一个事件调用多个方法。 方法不必与委托签名完全匹配。(委托中的协变和逆变) ...2008-06-11 14:43:00 · 74 阅读 · 0 评论 -
C#拾遗系列(2):属性
1. 这里主要演示属性的继承和覆盖2. 把属性理解为方法,实际上编译器就是把属性生成方法示例:using System;using System.Collections.Generic;using System.Linq;using System.Text; namespace NetTest{ public class TestPerpoerty { ...2008-06-11 14:54:00 · 69 阅读 · 0 评论 -
C#拾遗系列(2):属性
1. 这里主要演示属性的继承和覆盖2. 把属性理解为方法,实际上编译器就是把属性生成方法示例:using System;using System.Collections.Generic;using System.Linq;using System.Text; namespace NetTest{ public class TestPerpoerty { ...2008-06-11 14:54:00 · 78 阅读 · 0 评论 -
C#拾遗系列(3):构造函数
1. 主要演示构造函数的继承 声明空构造函数可阻止自动生成默认构造函数。 如果您不对构造函数使用访问修饰符,则在默认情况下它仍为私有构造函数。 通常显式地使用 private 修饰符来清楚地表明该类不能被实例化。 2. 静态构造函数 静态构造函数具有以下特点: ...2008-06-11 15:19:00 · 48 阅读 · 0 评论 -
C#拾遗系列(3):构造函数
1. 主要演示构造函数的继承 声明空构造函数可阻止自动生成默认构造函数。 如果您不对构造函数使用访问修饰符,则在默认情况下它仍为私有构造函数。 通常显式地使用 private 修饰符来清楚地表明该类不能被实例化。 2. 静态构造函数 静态构造函数具有以下特点: ...2008-06-11 15:19:00 · 64 阅读 · 0 评论 -
C#拾遗系列(4):索引器
1. 概述索引器允许类或结构的实例就像数组一样进行索引。索引器类似于属性,不同之处在于它们的访问器采用参数。索引器在语法上方便您创建客户端应用程序可将其作为数组访问的类、结构或接口。索引器经常是在主要用于封装内部集合或数组的类型中实现的。例如,假定具有一个名为 TempRecord 的类,此类表示在 24 小时内的 10 个不同时间记录的华氏度。此类包含一个表示温度的 float 类型的名为“...2008-06-11 15:30:00 · 80 阅读 · 0 评论 -
C#拾遗系列(4):索引器
1. 概述索引器允许类或结构的实例就像数组一样进行索引。索引器类似于属性,不同之处在于它们的访问器采用参数。索引器在语法上方便您创建客户端应用程序可将其作为数组访问的类、结构或接口。索引器经常是在主要用于封装内部集合或数组的类型中实现的。例如,假定具有一个名为 TempRecord 的类,此类表示在 24 小时内的 10 个不同时间记录的华氏度。此类包含一个表示温度的 float 类型的名为“...2008-06-11 15:30:00 · 69 阅读 · 0 评论 -
MSIL(0):简介
Microsoft Intermediate Language (MSIL)微软中间语言 MSIL是将.NET代码转化为机器语言的一个中间过程。它是一种介于高级语言和基于Intel的汇编语言的伪汇编语言。当用户编译一个.NET程序时,编译器将源代码翻译成一组可以有效地转换为本机代码且独立于CPU的指令。当执行这些指令时,实时(JIT)编译器将它们转化为CPU特定的代码。由于公共语言运行库...2009-03-04 23:06:00 · 142 阅读 · 0 评论 -
C#拾遗系列(5):泛型委托
using System;using System.Collections.Generic;using System.Linq;using System.Text; namespace NetTest{ //泛型委托 class TestGenericDelegate { public delegate void StackEventHa...2008-06-14 17:25:00 · 65 阅读 · 0 评论 -
C#拾遗系列(5):泛型委托
using System;using System.Collections.Generic;using System.Linq;using System.Text; namespace NetTest{ //泛型委托 class TestGenericDelegate { public delegate void StackEventHa...2008-06-14 17:25:00 · 58 阅读 · 0 评论 -
[tips]: 多线程 ManualResetEvent
WaitHandle用于实现对共享资源的独占访问,AutoResetEvent和ManualResetEvent都继承自它。 WaitHandle.WaitOne方法将阻塞当前线程,直到WaitHandle收到信号。但有时候,我们需要非阻塞的方式测试WaitHandle 状态。 public virtual bool WaitOne(int millisecondsTimeout)可以指定等...2009-05-21 14:23:00 · 164 阅读 · 0 评论