c# int uint32

C#Int32和C#UInt32 (C# Int32 and C# UInt32)

In C#, Int32 known as a signed integer of 4 bytes which can store both types of values including negative and positive between the ranges of -2147483648 to +2147483647.

在C#中, Int32被称为4字节的有符号整数,它可以存储-2147483648至+2147483647范围之间的两种类型的值,包括负数和正数。

UInt32 known as an unsigned integer of 4 bytes which can store only positive values between the ranges of 0 to 4294967295.

UInt32,它是4个字节的无符号整数 ,只能存储0到4294967295范围之间的正值。

'Int32'和'UInt32'之间的区别 (Differences between 'Int32' and 'UInt32')

Int32 UInt32
Int32 stands for signed integer. UInt32 stands for unsigned integer.
It's capacity to store the value is -2147483648 to +2147483647. It's capacity to store the value is 0 to 4294967295.
It can store negative and positive integers. It can store only positive integers.
It occupies 4-bytes space in the memory. It also occupies 4-bytes space in the memory.
Declaration syntax:
Int32 variable;
Declaration syntax:
UInt32 variable;
32位 UInt32
Int32代表有符号整数。 UInt32代表无符号整数。
它存储值的能力是-2147483648至+2147483647。 该值的存储容量为0到4294967295。
它可以存储负整数和正整数。 它只能存储正整数。
它在内存中占用4个字节的空间。 它还在内存中占用4字节的空间。
声明语法:
Int32变量;
声明语法:
UInt32变量;

Example:

例:

In this example, to explain the differences between Int32 and UInt32 in C#, we are printing their minimum and maximum values, we are also declaring two arrays – arr1 is a signed integer type and arr2 is an unsigned integer type. Initializing the arrays with corresponding negative and positive values based on their capacity.

在此示例中,为了解释C#中Int32和UInt32之间区别 ,我们将打印它们的最小值和最大值,同时还声明了两个数组– arr1是有符号整数类型,而arr2是无符号整数类型。 根据其容量用相应的负值和正值初始化数组。

using System;
using System.Text;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            //Int32 value range 
            Console.WriteLine("Int32 value capacity...");
            Console.WriteLine("Min: {0}, Max: {1}\n", Int32.MinValue, Int32.MaxValue);

            //UInt32 value range 
            Console.WriteLine("UInt32 value capacity...");
            Console.WriteLine("Min: {0}, Max: {1}\n", UInt32.MinValue, UInt32.MaxValue);

            //Int32 array
            Int32[] arr1 = { -2147483648, 0, 12320009, 2147480000, 2147483647 };
            Console.WriteLine("UInt32 array elements...");
            foreach (Int32 num in arr1)
            {
                Console.WriteLine(num);
            }
            Console.WriteLine();

            //UInt32 array
            UInt32[] arr2 = { 0, 100, 23000, 4294960000, 4294967295 };
            Console.WriteLine("UInt32 array elements...");
            foreach (UInt32 num in arr2)
            {
                Console.WriteLine(num);
            }

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

Output

输出量

Int32 value capacity...
Min: -2147483648, Max: 2147483647

UInt32 value capacity...
Min: 0, Max: 4294967295

UInt32 array elements...
-2147483648
0
12320009
2147480000
2147483647

UInt32 array elements...
0
100
23000
4294960000
4294967295


翻译自: https://www.includehelp.com/dot-net/Int32-and-UInt32-in-c-sharp.aspx

c# int uint32

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐