What is the equivalent of “(byte)” in VB.NET?

前端 未结 3 1891
刺人心
刺人心 2021-01-18 07:12

What is the equivalent of (byte) in VB.NET:

C#:

uint value = 1161;
byte data = (byte)value;

data = 137

VB.NET:<

3条回答
  •  囚心锁ツ
    2021-01-18 07:46

    Try first chopping the most significant bytes off the number, then converting it to Byte:

    Dim value As UInteger = 1161 
    Dim data1 As Byte = CType(value And 255, Byte)
    Dim data2 As Byte = CByte(value And 255)
    

提交回复
热议问题