c# int uint32_C#中Int32和UInt32之间的区别 偏执的太偏执、 2023-03-05 15:49 148阅读 0赞 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'**)** ## <table> <tbody> <tr> <th>Int32</th> <th>UInt32</th> </tr> <tr> <td><b>Int32</b> stands for signed integer.</td> <td><b>UInt32</b> stands for unsigned integer.</td> </tr> <tr> <td>It's capacity to store the value is -2147483648 to +2147483647.</td> <td>It's capacity to store the value is 0 to 4294967295.</td> </tr> <tr> <td>It can store negative and positive integers.</td> <td>It can store only positive integers.</td> </tr> <tr> <td>It occupies 4-bytes space in the memory.</td> <td>It also occupies 4-bytes space in the memory.</td> </tr> <tr> <td>Declaration syntax:<br><span>Int32 variable;</span></td> <td>Declaration syntax:<br><span>UInt32 variable;</span></td> </tr> </tbody> </table> <table> <tbody> <tr> <th> 32位 </th> <th> UInt32 </th> </tr> <tr> <td> <b>Int32</b>代表有符号整数。 </td> <td> <b>UInt32</b>代表无符号整数。 </td> </tr> <tr> <td> 它存储值的能力是-2147483648至+2147483647。 </td> <td> 该值的存储容量为0到4294967295。 </td> </tr> <tr> <td> 它可以存储负整数和正整数。 </td> <td> 它只能存储正整数。 </td> </tr> <tr> <td> 它在内存中占用4个字节的空间。 </td> <td> 它还在内存中占用4字节的空间。 </td> </tr> <tr> <td> 声明语法: <br> Int32变量; </td> <td> 声明语法: <br> UInt32变量; </td> </tr> </tbody> </table> **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][https_www.includehelp.com_dot-net_Int32-and-UInt32-in-c-sharp.aspx] c\# int uint32 [https_www.includehelp.com_dot-net_Int32-and-UInt32-in-c-sharp.aspx]: https://www.includehelp.com/dot-net/Int32-and-UInt32-in-c-sharp.aspx
还没有评论,来说两句吧...