ToUpper()、ToLower()

更改字符串大小;

  1. string programe="fdsahuiofdsaFDSHIUFDS";
  2. Console.WriteLine(programe);
  3. Console.WriteLine(programe.ToUpper());

Trim()

删除字符串前置空格与后置空格;

  1. string programe=" fdsahuiofdsaFDSHIUFDS ";
  2. Console.WriteLine(programe);
  3. Console.WriteLine(programe.Trim());

Contains(“x”)

匹配字符串中是否有“x”字符串,返回值为布尔类型;

  1. string pangram = "The quick brown fox jumps over the lazy dog.";
  2. Console.WriteLine(pangram.Contains("fox"));
  3. Console.WriteLine(pangram.Contains("cow"));

Random()

随机生成器

  1. Random rand=new Random();
  2. int coin=rand.next(0,2);

Math Class

Floor

返回小于或等于指定十进制数的最大整数值

Ceiling

返回大于或等于指定十进制数的最小整数值。

  1. int admiun = 123456;
  2. double adm = admiun / 2.0;
  3. int p = (int)Math.Floor(adm);
  4. int q = (int)Math.Ceiling(adm);