Archive for March, 2008

C# auto property

By admin - Last updated: Tuesday, March 25, 2008

ReSharper is good tool, it taught me the auto property in .NET 3.5 today. // traditional property declaration     public class Foo     {         private string _name;         public string Name         {             get { return _name; […]

C# Extension method, GetValueOrNull for value type object

By admin - Last updated: Wednesday, March 12, 2008

Return null if the value type object has default value. public static T? GetValueOrNull<t>( this T value ) where T : struct {    if( value.Equals( default( T ) ) )       return new Nullable<t>();    else       return value; } // Usage int i = default(int); //0 int? i = […]

ASP.NET:Get values of dynamically added controls.

By admin - Last updated: Wednesday, March 5, 2008

At the stage of OnInit, all control objects are performing initialization, if added controls were not initialized at this stage, and even though the postback data contain the values of those controls, you won’t be able to obtain the user inputed values of those controls at later stage. e.g. PageLoad, OnClickHandler method. In order to […]