包大人博客

迎奥运、讲文明、树新风 -- Welcome To Beijin 2008

About the author

Boris Yang
A troupe of little vagrants of the world, leave your footprints in my words.
E-mail me Send mail

Recent comments

Author

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

泛型代码中的 default 关键字 [C#]

    在泛型类和泛型方法中我们经常会遇到的一个问题是,在预先未知以下情况时,如何将默认值分配给参数化类型 T,主要有两个问题: T 是引用类型还是值类型。  如果 T 为值类型,则它是数值还是结构。     给定参数化类型 T 的一个变量 t,只有当 T 为引用类型时,语句 t = null 才有效;只有当 T 为数值类型而不是结构时,语句 t = 0 才能正常使用。但问题是我们使用泛型的初衷就是为了类或方法的通用性,类型安全性。我们不能只定义专门适用于引用类型的泛型类和方法,或者只定义适用... [More]

Currently rated 3.0 by 1 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,
Categories: .net | c# | FrameWork
Posted by Admin on Tuesday, April 01, 2008 10:51 AM
Permalink | Comments (0) | Post RSSRSS comment feed

具有验证实现的客户端回调 (ClientScriptManager 类)

    在客户端回调中,客户端脚本函数会向 ASP.NET 网页发送请求,该网页随后会运行其正常生命周期的简化版本以处理该回调。若要确保回调事件源于预期的用户界面 (UI),可以对回调进行验证。回调验证涉及在网页呈现过程中注册要验证的事件,然后在回调过程中对该事件进行验证。      对回调事件验证可通过ClientScriptManager类的 RegisterForEventValidation 方法和 ValidateEvent 方法。    &nb... [More]

Currently rated 2.0 by 1 people

  • Currently 2/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: asp.net | c#
Posted by Admin on Monday, March 31, 2008 4:10 PM
Permalink | Comments (0) | Post RSSRSS comment feed

ICallbackEventHandler 接口实现回调事件

    为任何需要接收回调事件的自定义控件实现 ICallbackEventHandler 接口。     实现 ICallbackEventHandler 接口的控件的示例包括 GridView、DetailsView 和 TreeView 控件。当回调事件以实现了 ICallbackEventHandler 接口的控件为目标时,将把事件变量作为参数传递来调用 RaiseCallbackEvent 方法以处理该事件,并且 GetCallbackResult 方法返回回调的结果。另外还需要获取一个对客户端函数的引用;调... [More]

Currently rated 2.0 by 1 people

  • Currently 2/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:
Categories: asp.net | c#
Posted by Admin on Monday, March 31, 2008 3:33 PM
Permalink | Comments (0) | Post RSSRSS comment feed

注册客户端脚本(ClientScriptManager 类)

    通过直接在网页的 HTML 标记中包含 script 脚本,可以声明方式向网页添加客户端脚本。然而,有些情况下需要动态添加客户端脚本。若要动态添加脚本,根据您想添加脚本的时间及方式,使用 RegisterClientScriptBlock 方法、RegisterClientScriptInclude 方法、RegisterStartupScript 方法或 RegisterOnSubmitStatement 方法。      这些方法都存在于ClientScriptManager 类中,ClientS... [More]

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:
Categories: asp.net | c#
Posted by Admin on Monday, March 31, 2008 1:46 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Lock 关键字实现线程同步 [C#]

    lock 关键字可以用来确保代码块完成运行,而不会被其他线程中断。这是通过在代码块运行期间为给定对象获取互斥锁来实现的。lock 语句以关键字 lock 开头,它有一个作为参数的对象,在该参数的后面还有一个一次只能由一个线程执行的代码块。lock 关键字将语句块标记为临界区,方法是获取给定对象的互斥锁,执行语句,然后释放该锁。 例如:         public void Function()     &n... [More]

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: c# | FrameWork
Posted by Admin on Saturday, March 29, 2008 3:38 PM
Permalink | Comments (0) | Post RSSRSS comment feed

处理不同线程间的信号通信

    先来假设一个实际的场景:想象在系统中存在这样的一种海量计算,我们把它分为5个计算单元 – A、B1、B2、B3、C。没一个单元都需要大量的运算,并且 A单元必须先完成,因为B1、B2 和 B3 需要 A的结果。而C又需要B1、B2 和 B3 的结果。     这种场景下,最好优先考虑的应该是多线程计算。比如为 A、B1、B2 和 B3 各创建一个线程,C单元在主线程中运算,但考虑到各个单元之间有着依赖关系,我们可以清楚看到:C的计算必须等待 B1、B2 和 B3 三个单元运算都结束,而 B1、B2 ... [More]

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: c# | FrameWork
Posted by Admin on Saturday, March 29, 2008 2:42 PM
Permalink | Comments (0) | Post RSSRSS comment feed

C# 泛型简介

 [参考MSDN] http://msdn2.microsoft.com/zh-cn/library/ms379564(vs.80).aspx(中文)                      http://msdn.microsoft.com/vcsharp/default.aspx?pull=/library/en-us/dnvs05/html/csharp_generics.... [More]

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,
Categories: c# | FrameWork
Posted by Admin on Monday, March 24, 2008 11:56 AM
Permalink | Comments (0) | Post RSSRSS comment feed

妙用 C# yield 关键字

       C#中的 yield 关键字用来在迭代器块中用于向枚举数对象提供值或发出迭代结束信号。.net 2.0 开始提供,本篇post就来揭示一下它的作用,蛮cool的嗷。 迭代背景    foreach 我们经常使用,常常用 "foreach" 来遍历一个 object (array, collection, etc), 但我们知道这个object必须是实现 IEnumerable 或 IEnumerable<T>接口的 - 泛型IEnumerable... [More]

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by Admin on Tuesday, March 04, 2008 6:08 PM
Permalink | Comments (0) | Post RSSRSS comment feed