1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 用于将类型从double转换为int的C#程序

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

时间:2020-04-16 07:56:41

相关推荐

用于将类型从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 conversionb = (int)a;Output:a: 123456.789b: 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 conversionb = (int)a;Console.WriteLine("value of a: {0}", a);Console.WriteLine("value of b: {0}", b);//hit ENTER to exit the programConsole.ReadLine();}}}

Output

输出量

value of a: 123456.789value of b: 123456

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

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。