bloggerads

2013年1月3日 星期四

C# : Basic knowledge notes

// int to string

int iValue = 4;
string sResult = iValue.ToString();
string sResult = iValue.ToString("X16");  // int to Hex string

// string to int

string num = "-105";
int numVal = Int32.Parse(num);

// string array

string[] lines= new string[] { "Param1", "Param2" };

Array.Clear(lines, 0, lines.Length); // Clear all (Won't resize)


// Debugging
try
{

}
catch (Exception e) 
{
    Console.WriteLine(e.Message);
}
finally
{
    // Code always goes to here!

}

// Declare Dictionary

Dictionary<string, string> map = new Dictionary<string, string>();

// Declare List
List<int> list = new List<int>();

沒有留言:

張貼留言