【你吐吧c#每日学习】11.10 C# Data Type conversion
2024-10-18 18:16:15
implicit
explicit
float f=12123456.213F
int a = Convert.ToInt32(f); //throw exception or
int a = (int)f; // not throw exception nut got an overflow value
parse and tryparse
string to other datatype
string a="100fh";
int num=int.Parse(a); //throw exception
int result=0;
bool isNum=int.TryParse(num,out result);
if(isNum){ Console.WriteLine(result);
}else{
Console.WriteLine("Invalid")}
最新文章
- [C#] 简单的 Helper 封装 -- SecurityHelper 安全助手:封装加密算法(MD5、SHA、HMAC、DES、RSA)
- 半连通分量--Tarjan/Kosaraju算法
- Serializable 序列化
- 判断手机,pc方式登录
- 用xshell操作linux系统的常用命令
- [Java] JSTL格式化时间计算时差
- 剖析iphone之触摸事件touchstart
- AFNetworking自我总结
- 【转载】基于vw等viewport视区相对单位的响应式排版和布局
- 有序的Map集合--LinkedHashMap
- openstack项目【day23】:KVM介绍
- WebDriver高级应用实例(8)
- psutil库
- CDH5.11安装spark2.x详细步骤
- 密码记录工具keepass保存密码
- vue使用过程中的一些小技巧
- DICOM中的入门概念
- IntelliJ IDEA 插件开发视频教程
- idea 编辑时cup飙升解决方案,亲测有效
- BZOJ 1316: 树上的询问