博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C#Convert.ToInt32(bool)方法-将bool值转换为int
阅读量:2532 次
发布时间:2019-05-11

本文共 1159 字,大约阅读时间需要 3 分钟。

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) : 1Convert.ToInt32(false): 0Convert.ToInt32(a) : 1Convert.ToInt32(b): 0

翻译自:

转载地址:http://oyazd.baihongyu.com/

你可能感兴趣的文章
哈希(1) hash的基本知识回顾
查看>>
Leetcode 6——ZigZag Conversion
查看>>
dockerfile_nginx+PHP+mongo数据库_完美搭建
查看>>
Http协议的学习
查看>>
【转】轻松记住大端小端的含义(附对大端和小端的解释)
查看>>
设计模式那点事读书笔记(3)----建造者模式
查看>>
ActiveMQ学习笔记(1)----初识ActiveMQ
查看>>
Java与算法之(2) - 快速排序
查看>>
Windows之IOCP
查看>>
机器学习降维之主成分分析
查看>>
CTP2交易所成交回报
查看>>
WebSocket & websockets
查看>>
openssl 升级
查看>>
ASP.NET MVC:通过 FileResult 向 浏览器 发送文件
查看>>
CVE-2010-2883Adobe Reader和Acrobat CoolType.dll栈缓冲区溢出漏洞分析
查看>>
使用正确的姿势跨域
查看>>
AccountManager教程
查看>>
Android学习笔记(十一)——从意图返回结果
查看>>
算法导论笔记(四)算法分析常用符号
查看>>
ultraedit激活
查看>>