The program is tested in the console program   , The following two methods are introduced , The code is as follows :
using System; namespace ConsoleApp17 { class Program { static void
Main(string[] args) { //double ➡ int //A method : Convert.Toint32(double) ➡ int : rounding
【 special ①】 //B method : (int)double ➡ Remove decimal double a = 3.4; double c = 3.6;
Console.WriteLine( Convert.ToInt32(a) +"\n"+ Convert.ToInt32(c) +"\n"+ (int)a
+"\n"+ (int)c +"\n" ); //【①】 If the decimal is in the middle of two integers , Then the integer is even , Not odd double b = 3.5;
double bb = 4.5; Console.WriteLine( Convert.ToInt32(b) + "\n" +
Convert.ToInt32(bb) + "\n" ); // If the parameter is Null,A Method correspondence 0,B Method error Console.WriteLine(
Convert.ToInt32(null) +"\n" //+ (int)null report errors ); //String ➡ int //A method :int
int.parse(String s); s If the format is not correct , Will report a mistake //B method : bool int.Tryparse(String s ,out int a);
If abnormal ,a=0, And return false String rightString = "2018"; String errorString = "liuyan";
Console.WriteLine( int.Parse(rightString) ); //int.Parse(errorString); report errors int
result3, result4; int.TryParse(rightString,out result3);
int.TryParse(errorString,out result4); Console.WriteLine(result3+"\n"+result4);
Console.Read(); } } }
Print as follows :

 

 

 

 

Technology
©2020 ioDraw All rights reserved
django Do not close CSRF middleware , Custom through CSRF Tested post request Understanding neural network machine translation in three minutes error: (-215:Assertion failed) Solution ETL tool kettle And datax Comparison test cases Oracle to Oracle Tiktok The matrix - Code rain ( Free delivery ) Interview questions : Handwritten list ( Include reverse linked list )-bash The Trojan horse , Have you ever met one ? Implementation and challenge of metadata service in data Lake PHP call shell command Notes on core principles of reverse engineering ( One )——Hello World-1