C# 程序将 Byte 值转换为 Int32 值
csharpprogrammingserver side programming更新于 2025/9/14 0:17:00
要将 Byte 值转换为 Int32 值,请使用 Convert.ToInt32() 方法。
Int32 表示 32 位有符号整数。
假设以下是我们的 Byte 值。
byte val = Byte.MaxValue;;
现在将其转换为 Int32。
int intVal = Convert.ToInt32(val);
让我们看一下完整的例子。
示例
using System;
public class Demo {
public static void Main() {
byte val = Byte.MaxValue;;
int intVal = Convert.ToInt32(val);
Console.WriteLine("Converted byte {0} to Int32 {1} value ", val, intVal);
}
}
输出
Converted byte 255 to Int32 255 value

