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

Convert.ToInt32(bool) Method is used to convert a specific Boolean (bool) value to its equivalent integer (int 32 signed number).

Convert.ToInt32(bool)方法用于将特定的布尔值(布尔值)转换为其等效的整数(32位带符号整数)。

Syntax:

句法:

    int Convert.ToInt32(bool value);

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

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

Example:

例:

    Input:
bool a = true;
Output:
1

Code:

码:

using System;
using System.Text;
namespace Test
{class Program
{static void Main(string[] args)
{Console.WriteLine("Convert.ToInt32(true) : " + Convert.ToInt32(true));
Console.WriteLine("Convert.ToInt32(false): " + Convert.ToInt32(false));
bool a = true;
bool b = false;
Console.WriteLine("Convert.ToInt32(a) : " + Convert.ToInt32(a));
Console.WriteLine("Convert.ToInt32(b): " + Convert.ToInt32(b));
//hit ENTER to exit
Console.ReadLine();
}
}
}

Output

输出量

Convert.ToInt32(true) : 1
Convert.ToInt32(false): 0
Convert.ToInt32(a) : 1
Convert.ToInt32(b): 0

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

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

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

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

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

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

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

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

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

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

  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. Django项目配合sentry实现浅析
  2. enterText与typeText
  3. ajax spring mvc 接收json数据,easyui ajax请求获取SpringMVC @ResponseBody返回的Json数据为什么非得eval才能通过对象获取值?...
  4. JavaScript中map函数和filter的简单举例
  5. mongdb 建立了索引唯一性还能重复插入?_「数据库系列」Postgres性能调优——Index...
  6. oauth2 access_denied 不允许访问_OAuth 2 是什么-入门介绍
  7. mysql基础之四:int(M)中M的含义
  8. SQLServer 数据库主体在该数据库中拥有 架构,无法删除解决方法
  9. ​供应链管理-ERP的前世今生
  10. mysql 排序取前4,mysql分组取每组前几条记录(排序)
  11. 小学计算机课程报告怎么写,小学计算机课论文摘要怎么写 小学计算机课论文摘要范文参考...
  12. java 送参数_关于java:如何以编程方式发送带参数的HTTP请求?
  13. 活动目录AD 取用户过期时间accountExpires
  14. 学习python: x+=1 与 x = x + 1
  15. 在ASP.NET中执行URL重写(一)
  16. 关于FlyMcu和XCOM软件下载程序的使用(关于STM32F4实现串口通信后续)
  17. Laravel之队列
  18. nc65 树单据类型教程
  19. pdf转换成word后有文字叠加_pdf转成word后格式快速调整
  20. qss 属性介绍大全

热门文章

  1. react-native页面间传递数据的几种方式
  2. 游戏大厅 从基础开始(6)--绕回来细说聊天室(中)之女仆编年史1
  3. Ubuntu|ython3 :ImportError: cannot import name 'main'
  4. HDP 2.6 requires libtirpc-devel
  5. 从mysql向HBase+Phoenix迁移数据的心得总结
  6. 简单的GTK窗体搭建
  7. mock接口开发,excel(读,写,修改)
  8. Array的用法总结-swift
  9. java 对象的上转型对象(父类)
  10. strlen的神奇实现