C#Convert.ToInt32(char)方法 (C# Convert.ToInt32(char) Method)

Convert.ToInt32(char) Method is used to convert a specific char value to its equivalent integer (int 32 signed number) (It can also be known as ASCII value).

Convert.ToInt32(char)方法用于将特定的char值转换为其等效的整数(int 32带符号的数字)(也称为ASCII值)。

Syntax:

句法:

    int Convert.ToInt32(char value);

It accepts a char value/variable as an argument and returns its equivalent signed integer.

它接受一个char值/变量作为参数,并返回其等效的带符号整数。

Example:

例:

    Input:
char a = 'A';
Output:
65

Code:

码:

using System;
using System.Text;
namespace ConsoleApplication3
{class Program
{static void Main(string[] args)
{char a = 'A'; //uppercase A
char b = 'z'; //lowercase z
Console.WriteLine("value of a: {0}, type of a: {1}", a, a.GetType());
Console.WriteLine("value of b: {0}, type of b: {1}", b, b.GetType());
//converting to Int32 & printing values & types
Console.WriteLine("value: {0}, type: {1}", Convert.ToInt32(a), Convert.ToInt32(a).GetType());
Console.WriteLine("value: {0}, type: {1}", Convert.ToInt32(b), Convert.ToInt32(b).GetType());
//hit ENTER to exit
Console.ReadLine();
}
}
}

Output

输出量

value of a: A, type of a: System.Char
value of b: z, type of b: System.Char
value: 65, type: System.Int32
value: 122, type: System.Int32

翻译自: https://www.includehelp.com/dot-net/Convert-ToInt32-char-method-in-c-sharp.aspx

C#Convert.ToInt32(char)方法-将char值转换为int相关推荐

  1. C#Convert.ToInt32(object)方法-将对象值转换为int

    C#Convert.ToInt32(object)方法 (C# Convert.ToInt32(object) Method) Convert.ToInt32(object) Method is us ...

  2. C#Convert.ToInt32(bool)方法-将bool值转换为int

    C#Convert.ToInt32(bool)方法 (C# Convert.ToInt32(bool) Method) Convert.ToInt32(bool) Method is used to ...

  3. C#Convert.ToInt32(byte)方法-将字节值转换为int

    C#Convert.ToInt32(byte)方法 (C# Convert.ToInt32(byte) Method) Convert.ToInt32(byte) Method is used to ...

  4. C#Convert.ToInt32(long)方法-将long值转换为int

    C#Convert.ToInt32(long)方法 (C# Convert.ToInt32(long) Method) Convert.ToInt32(long) Method is used to ...

  5. Java面试题:IO流中read()方法为什么返回值是int

    Question:IO流中read()方法为什么返回值是int? anwser:因为字节输入流可以操作任意类型的文件,比如图片音频等,这些文件底层都是以二进制形式的存储的,如果每次读取都返回byte, ...

  6. iBaits中,关于insert返回值的问题(注意!!!不必写resultClass= java.lang.Integer,方法的返回值就是int)

    今天工作中使用iBaits写SQL,其中一个是insert语句 在sqlMap中我这么写了,<insert parameterClass="...." resultClass ...

  7. 两字节16进制值转换为int

    有时候在报文中会碰到以两个字节来存出一个整型的数据,例如0x0080,将其重新转换成int的方法是: char a = 0x80;//低位 char b = 0x00;//高位int value = ...

  8. 在 C# 中,(int) ,Int32.Parse() 和 Convert.toInt32() 三种方法的区别

    在 C# 中,(int),Int32.Parse() 和 Convert.toInt32() 三种方法有何区别? int 关键字表示一种整型,是32位的,它的 .NET Framework 类型为 S ...

  9. (int),Int32.Parse() 和 Convert.toInt32() 的区别

    在 C# 中,(int),Int32.Parse() 和 Convert.toInt32() 三种方法有何区别? int 关键字表示一种整型,是32位的,它的 .NET Framework 类型为 S ...

最新文章

  1. python accept解析_python中requests库使用方法详解
  2. java arraystoreexception_208道高频 Java面试题答案6
  3. 算法基础之搜索和经典排序
  4. node.js Express框架入门
  5. [工具类]DataTable与泛型集合List互转
  6. JAVA笔记--数组和字符串常用方法
  7. 百练(九~十二)题解
  8. npm ERR! path D:\NodeWWW\webpack\node_modules\fsevents\node_modules
  9. ASP.NET 事件日历(some resource about Event Calendar)
  10. CAVLC基于上下文自适应的可变长编码
  11. 2020年华为鲲鹏产业体系研究深度报告
  12. 词汇处理——词义辨析消歧(一)
  13. 出现Head https://registry-1.docker.io/v2/library/node/manifests/14-alpine的解决方法
  14. 《图解HTTP》阅读总结(上)
  15. 学生信息管理系统中系统登录问题
  16. 【NLP】NLP领域的国内外专家(Greedy_AI)
  17. airbnbs收入预测数据平台
  18. 微信公众号文章错别字修改上限调整了?
  19. CCF 201703-1分蛋糕
  20. 联想微型计算机内容不清楚,联想L2060wa显示器显示不清楚,特别是文字更无法看...

热门文章

  1. [2021-CVPR] Jigsaw Clustering for Unsupervised Visual Representation Learning 论文简析及关键代码简析
  2. 计算机应用与基础实践怎么考,自考计算机基础应用科目笔试和实践性考试怎么考...
  3. android聚焦时如何给控件加边框,edittext设置获得焦点时的边框颜色
  4. python收集数据程序_基于Python语言的互联网数据收集软件的设计
  5. 山海伏妖录java_山海伏妖录攻略大全 剧情结局加点妖兽大全
  6. ansible--- tags
  7. linux用户和用户组
  8. Redis(一):什么是NoSQL与NoSQL分类
  9. Investigating Div-Sum Property【数位DP】
  10. openlayers5之热力图heatmap