Wednesday, July 18, 2012

Comparing Two String


/// <summary>
/// Two String Comparision in C#
/// </summary>
public void CompareTwoString()
{
string str1 = "sunil";
string str2 = "priyanka";


if (str1.Equals(str2))
{
Console.WriteLine("string equals");
}
else
{
Console.WriteLine("string not equals");
}
}

Sunday, July 8, 2012

windows identity foundation (microsoft.identitymodel.dll) missing from window7


Installing windows identity foundation for windows 7.

Install following two components for Windows Identity Foundation:

Windows Identity Foundation runtime
http://www.microsoft.com/en-us/download/details.aspx?id=17331

Windows identity foundation (WIF)
http://www.microsoft.com/en-us/download/details.aspx?id=4451

Following reference will be available for adding in project : "C:\Program Files\Reference Assemblies\Microsoft\Windows Identity Foundation\v3.5\Microsoft.IdentityModel.dll"

Tuesday, July 3, 2012

String to Boolean conversion

Issue:
Getting excel data in code as string, even Boolean data is coming as string and wanted to change it to boolean (true or false).

Solution:
Use function Convert.ToBoolean(value).
If value is null method will return false.
if value is 0 method will return false.
if value is False(string) method will return false.
if value is 1 method will return true.
if value is True(string) method will return true.

Example:
bool UIOKtoSyndicateCheckBoxChecked = Convert.ToBoolean(Data.GetValue("OkToSyndicate"));