random
Random item = new Random();
for (int i = 0; i < 10; i++) {
int result = item.Next(0, 10);
Console.WriteLine(result); }
String compare to string: this compare the ASCII number, a>b=1, a=b=0, a<b=-1;
string a = "Brown";
string b = "brown";
int c = a.CompareTo(b);
Console.WriteLine(c);
方法 IndexOf / LastIndexOf/StartWith/Endwith
Concat/ join/split /Trim/string.IsNullOrEmpty(str);
Some is method for string, some is method for variable.
string str1= "AB,CD,EFG";
string[] intArr = str1.Split(new char[] { ',' });
foreach (object o in intArr) {
Console.WriteLine(o);
Console.WriteLine(o.GetType());
}
string str1= "AB,CD,EFG";
string str2= str1.Replace("A", "b");
string str2= str1.ToLower();
Console.WriteLine(str2);
DateTime time2 = DateTime.Now;
string time3 = time2.ToString();