DateTime in C#

Convert DateTime to a string with a relevent format


var usCultureInfo = new CultureInfo ("en-US", false);
var date = new DateTime (2012, 3, 22, 15, 6, 0);
date.ToString ("MM/dd/yy", usCultureInfo);

Binding a Dictionary to a Drop Down List

Binding data from a Dictionary is not so challenging as “Key” and “Value” pairs can be used for the drop down list properties. Following code samples show the results after assigning data source to the drop down list.

Before

Dictionary genderDictionary = new Dictionary();
genderDictionary.Add(1, "Male");
genderDictionary.Add(2, "Female");
genderDictionary.Add(3, "Transgender");

this.ddlGender.DataSource = genderDictionary;
this.ddlGender.DataBind();

Before Assign Key Value Pair

Continue reading “Binding a Dictionary to a Drop Down List”

Find public key token for a .NET DLL or assembly

You can get the public key token by using following command. Keep in mind that the dll should be a “Strongly Typed” one.


c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>sn -T C:\sdk\Microsoft.Xr
m.Sdk.dll


Microsoft (R) .NET Framework Strong Name Utility  Version 4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.


Public key token is 31bf3856ad364e35