AC# 类型转换
2021-06-08 08:03
标签:bool 范围 main null click ace char console app 隐式类型转换 显式类型转换 要注意范围是否超出 null转了之后还是null,""转了之后还是""。 AC# 类型转换 标签:bool 范围 main null click ace char console app 原文地址:https://www.cnblogs.com/mlh1421/p/10699878.htmlusing System;
namespace App{
class MyClass{
public static void Main(string[] args){
char a=‘A‘;
int b=a;
Console.WriteLine(b);//65
Console.WriteLine(a);//A
}
}
}
double a=10.902;
int b=(int) a;
Console.WriteLine(b);//10
Console.WriteLine(a);//10.902
string str = "56561515";
int b = System.Convert.ToInt32(str);
Console.WriteLine(b);//10.902
using System;
namespace App{
class MyClass{
public static void Main(string[] args){
//string str= Convert.ToString(null);
bool str= Convert.ToString(null)==null;//True
Console.WriteLine(str);
}
}
bool str= Convert.ToString("")=="";//True
Console.WriteLine(str);