Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > .NET > C#.NET > 关于.NET(C#)中字符型(Char)与数字类型的转换, CLR via c# 读书笔记
【标  题】:关于.NET(C#)中字符型(Char)与数字类型的转换, CLR via c# 读书笔记
【关键字】:.NET,C#,Char,CLR,via,c#
【来  源】:http://blog.csdn.net/skywind_jk/archive/2007/04/19/1570061.aspx

关于.NET(C#)中字符型(Char)与数字类型的转换, CLR via c# 读书笔记

Your Ad Here

 

原文:http://www.free56.cn/post/27.html

.NET中字符型(Char)与数字类型的转换 -- “CLR via C# ”读书笔记 (http://free56.cn)
三种实现方式,强制转换(Casting),使用System.Convert方法,使用IConvertible接口。其中,从效率来考虑,强制转换(Casting)效果最佳,因为在编译器编译时,会生成IL,而IL本身即可实现该转换,无需调用其他转换功能;使用IConvertible接口效果最差,因为实现时,还涉及到拆箱/装箱操作。

Convert between Char and various numeric types in .NET
(Afer read the "CLR via C#") (http://www.free56.cn)

There are 3 ways to convert between numertic types and Char instance, they are Casting, System.Convert method and IConvertible interface. I always use the Casting method, because it is  easy to use. And now ,after read the "CLR via C#", I know, that it is also the best and most efficient way to complete the convert function! The Casting Method as follows:
char c = (char) 65; // the char c is 'A'
int i = (int) 'A'; // the int i is 65

why it is the best way ? It is because the compiler emits intermediate language (IL) instructions to perform the conversion, and no methods have to be called. Interesting? So use it in this way!

The two other method... ... Please go to http://www.free56.cn/post/27.html

(http://www.free56.cn)

ASP.NET 2.0 AJAX Webservice调用 返回DataTable 新解:【上一篇】
简单状态机Workflow基于Web应用:【下一篇】
【相关文章】
  • ASP.NET 2.0 AJAX Webservice调用 返回DataTable 新解
  • asp.net动态加载用户控件问题解决日记
  • 用c#和和.net创建Infopath中的自定义控件
  • C#运用存储过程1
  • 在PHP中使用ASP.NET AJAX
  • .net 自用代码大全天天收藏(C#版)
  • asp.net2.0 javascript 回调服务器端方法
  • Asp.Net Trace
  • C#使用AD数据库中的人员信息
  • .NET2.0抓取网页全部链接
  • 【随机文章】
  • 解决Windows Firewall/Internet Connection Sharing(ICS) 错误 10106
  • Servlet/JSP服务器端的重定向
  • 用Soft-ICE实现源码级调试
  • 表达意思有多难之二--改进
  • 一些特效代码,与大家分享(十二)
  • ASP.NET 2.0中DataTable小兵变大将
  • 已有一定规模的“软件配置管理QQ群”,诚邀广大专业人士加入并参与讨论
  • 使用SharePoint提供的WebService进行列表的增删改
  • ORACLE数据库常见问题诊断方法 ---(常见错误篇)
  • 什么是最理想的软件保护方法
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.