c#里面int.关键字_C#中的int关键字

c#里面int.关键字

C#int关键字 (C# int keyword)

In C#, int is a keyword which is used to declare a variable that can store an integral type of value (signed integer) the range of -2,147,483,648 to 2,147,483,647. int keyword is an alias of System.Int32.

在C#中, int是关键字,用于声明一个变量,该变量可以存储值范围为-2,147,483,648到2,147,483,647的整数类型(带符号整数)。 int关键字是System.Int32的别名。

It occupies 4 bytes (32 bits) space in the memory.

它在内存中占用4个字节(32位)的空间。

Syntax:

句法:

    int variable_name = value;

C#代码演示int关键字的示例 (C# code to demonstrate example of int keyword)

Here, we are declaring an int variable num, initializing it with the value 12345 and printing its value, type, and size of an int type variable.

在这里,我们声明一个int变量num ,将其初始化为值12345并打印其值,类型和int类型变量的大小。

using System;
using System.Text;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            //variable declaration
            int num = 12345;

            //printing value
            Console.WriteLine("num: " + num);
            //printing type of variable
            Console.WriteLine("Type of num: " + num.GetType());
            //printing size
            Console.WriteLine("Size of a int variable: " + sizeof(int));
            //printing minimum & maximum value of int
            Console.WriteLine("Min value of int: " + int.MinValue);
            Console.WriteLine("Max value of int: " + int.MaxValue);

            //hit ENTER to exit
            Console.ReadLine();
        }
    }
}

Output

输出量

num: 12345
Type of num: System.Int32
Size of a int variable: 4
Min value of int: -2147483648
Max value of int: 2147483647


翻译自: https://www.includehelp.com/dot-net/int-keyword-in-c-sharp.aspx

c#里面int.关键字

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值