Public voidTypeconvert () {intA = A; Doubleb =35.5; Console.WriteLine ((int) b);//Display Type Conversions//coercion type conversion with convert, parseString s ="123"; inti =int. Parse (s); intj =Convert.ToInt32 (s); Console.WriteLine ("{0} {1}", i,j); //This is also the way to convert a string of numeric content to an int type, but that way is more than int. Parse (string s) is better, it does not show an exception. The last parameter, result, is the output value, and if the conversion succeeds, the corresponding value is output, and the conversion fails to output 0. stringS1 ="ABCD"; stringS2 ="1234"; intC, D; BOOLBo1 =int. TryParse (S1, outc); Console.WriteLine (S1+" "+ Bo1 +" "+c); BOOLBo2 =int. TryParse (S2, outd); Console.WriteLine (S2+" "+ Bo2 +" "+d); String Str="ABC"; CharCH ='a'; Console.WriteLine (str. ToUpper ()); Console.WriteLine (B.tostring ()); Console.WriteLine (Ch.compareto ('D')); }
C # type conversion related