用于将类型从double转换为int的C#程序

Given a double type of variable, we have to convert it into an integer in C#.

给定双重类型的变量,我们必须在C#中将其转换为整数。

Syntax:

句法:

    int_variable = (int)double_variable;

Example:

例:

    Input:
double a = 123456.789;
int b = 0;
//type conversion
b = (int)a;
Output:
a: 123456.789
b: 123456

C# code for type conversion from double to int

用于将类型从double转换为int的C#代码

// C# program for type conversion from double to int 
using System;
using System.IO;
using System.Text;
namespace IncludeHelp
{
class Test
{
// Main Method 
static void Main(string[] args)
{
double a = 123456.789;
int b = 0;
//type conversion
b = (int)a;
Console.WriteLine("value of a: {0}", a);
Console.WriteLine("value of b: {0}", b);
//hit ENTER to exit the program
Console.ReadLine();
}
}
}

Output

输出量

value of a: 123456.789
value of b: 123456

翻译自: https://www.includehelp.com/dot-net/type-conversion-from-double-to-int.aspx

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/380802.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

ASCII码

ASCII 码使用指定的7 位或8 位二进制数组合来表示128 或256 种可能的字符。标准ASCII 码也叫基础ASCII码,使用7 位二进制数(剩下的1位二进制为0)来表示所有的大写和小写字母,数字0 到9、标点符号,以及在美式英语中使用…

如果有一天生你养你的两个人都走了

如果有一天 生你养你的两个人都走了 这世间唯一与你有着最亲密血缘关系的人都不在了 所以 孩子们啊 人在世的时候 要对父母好点 别让父母总是为你们操心 父母不需要你挣多少钱 但他们很需要子女的陪伴 因为子女是父母最深的牵挂如果有一天 生你养你的两个人都走了 这世间…

MySQL 纯insert_MySQL使用INSERT插入多条记录

MySQL使用INSERT插入多条记录,应该如何操作呢?下面就为您详细介绍MySQL使用INSERT插入多条记录的实现方法,供您参考。看到这个标题也许大家会问,这有什么好说的,调用多次INSERT语句不就可以插入多条记录了吗&#xff0…

php中对ASCII码的处理ord() 、chr()

和ASCII有关的部分函数 ord(): 函数返回字符串的首个字符的 ASCII 值 <?phpheader(content-type:text/html;charsetutf-8);echo ord(A),<br>;echo ord(ABC),<br>; ?>chr():指定的 ASCII 值返回字符&#xff0c;ASCII 值可被指定为十进制值、八进制值或十…

c# sizeof_C#程序演示sizeof()运算符的示例

c# sizeofC&#xff03;sizeof()运算符 (C# sizeof() operator) It is used to obtain the size of a data type in bytes (primitive data type). 它用于获取以字节为单位的数据类型的大小(原始数据类型)。 Syntax: 句法&#xff1a; sizeof(type);sizeof(int); //returns 4…

高手要耐得住寂寞

应该有不少高手会抱怨&#xff1a;为什么CSDN首页推荐的都是一些没有技术含量的文章&#xff1f;而我自己写的含金量非常高的&#xff0c;却很少能获得推荐&#xff1f; 其实这是一个很有意思的问题。程序员这职业&#xff0c;和别的职业相比&#xff0c;所占的人口比率肯定不高…

PHP中字符串定界符

作用&#xff1a;为输出大量的文本提供简单方法 格式&#xff1a; <<<名字 //代码 名字;注意&#xff1a; 开始和结束的名字必须一样&#xff0c;名字的命名格式和变量一样&#xff0c;结束的名字必须顶格写 <?phpheader(content-type:text/html;charsetutf-8);…

c语言 函数的参数传递示例_nexttoward()函数以及C ++中的示例

c语言 函数的参数传递示例C nexttoward()函数 (C nexttoward() function) nexttoward() function is a library function of cmath header, it is used to get the next representable value after the given first number in the direction of given second number, it accep…

java实现递归层次遍历_Java实现二叉树的前序、中序、后序、层序遍历(递归方法)...

在数据结构中&#xff0c;二叉树是树中我们见得最多的&#xff0c;二叉查找树可以加速我们查找的效率&#xff0c;那么输出一个二叉树也变得尤为重要了。二叉树的遍历方法分为四种&#xff0c;分别为前序遍历、中序遍历、后序、层序遍历。下图即为一个二叉树。前序遍历&#xf…

Object之MemberwiseClone方法

示例: 代码 usingSystem;usingSystem.Collections.Generic;usingSystem.Configuration;usingSystem.Data;usingSystem.Linq;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.HtmlControls;usingSystem.Web.UI.WebControls;usingSystem.Web.UI…

php数组的声明和类型

数组的声明 方法一&#xff1a;使用array()&#xff0c;自动分配索引&#xff0c;从0开始 <?phpheader(content-type:text/html;charsetutf-8);$personarray("DL_one",18,man);print_r($person); ?>方法二&#xff1a;手动分配索引 <?phpheader(conte…

np.isfinite_带有Python示例的math.isfinite()方法

np.isfinitePython math.isfinite()方法 (Python math.isfinite() method) math.isfinite() method is a library method of math module, it is used to check whether a given number is a finite number of not, it accepts a number (integer/float, finite, infinite or N…

java的或等于_Java中的“小于或等于”比较运算符是__________: !=|||=|=

Java中的“小于或等于”比较运算符是__________: !|答&#xff1a;<“ 87 版”电视剧《红楼梦》中歌曲的作曲者是( )。答&#xff1a;王立平宏观经济周期循环的扩张过程包括( )。答&#xff1a;繁荣 复苏关于移动互联网的说法正确的是&#xff1a;答&#xff1a;以上都是机体…

css degrees_带有Python示例的math.degrees()方法

css degreesPython math.degrees()方法 (Python math.degrees() method) math.degrees() method is a library method of math module, it is used to convert angle value from radians to degree, it accepts a number and returns the angle value in degree. math.degrees(…

深入浅出SharePoint2010——附录:常用术语对照

MOSS&#xff08;Microsoft Office SharePoint Server&#xff09;转载于:https://www.cnblogs.com/mingle/archive/2010/12/20/1911910.html

php数组的下标、extract函数

下标的变化 用例子解释&#xff0c;看懂了例子就知道了&#xff0c;很简单&#xff0c;就不解释了 <?phpheader(content-type:text/html;charsetutf-8);$numarray(0>1,2,3,4);print_r($num);echo <br>;$numarray(1,2>2,3,4);print_r($num);echo <br>;$…

python中三级菜单讲解_Python字典实现简单的三级菜单(实例讲解)

导读热词H_403_2如下所示&#xff1a;data {"北京":{"昌平":{"沙河":["oldboy","test"],"天通苑":["链接地产","我爱我家"]},"朝阳":{"望京":["奔驰","…

python中pow函数_pow()函数以及Python中的示例

python中pow函数Python pow()函数 (Python pow() function) pow() function is a library function in Python, is used to get the x to the power of y, where x is the base and y is the power – in other words we can say that pow() function calculates the power i.e…

php多维数组

php多维数据我的理解是一个数组的元素是数组&#xff0c;然后又嵌套&#xff0c;就变成多维数组了&#xff0c;比如说二维数组是一维数组的元素变成数组就成二维数组了 <?phpheader(content-type:text/html;charsetutf-8);$cars array(array("Volvo",100,96),a…

python函数与模块学习_Python函数与模块学习1

函数实现具有特定功能的代码自定义函数 内置函数函数特点隐藏实现功能的细节重用代码提高可读性&#xff0c;便于调试函数的定义def 函数名(形式参数1&#xff0c;形式参数2&#xff0c;……形参n)&#xff1a;要运行的代码(函数体)return 输出的数据(返回值)形式参数&#xff…