What it's going to do is take the 0th & 7th character from the tempRMACode string, convert those values to Bytes and then add them. Convert is applied to the ASCII value of the character. So Convert.ToByte("A") == 65
the ASCII value of A
.
String.Format("{0:X2}", temp8bit)
is going to take the numeric value of temp8bit
and give you the HEX value. So if you had the number 121 in temp8bit, you'd get 79 in rmaValidationCode.
Given the following:
Dim temp8bit As Byte
Dim tempRMACode As String = "A234567890"
Dim rmaValidationCode As String = String.Empty
temp8Bit = 0
temp8bit = Convert.ToByte(tempRMACode.ToCharArray().GetValue(0)) _
+ Convert.ToByte((tempRMACode.ToCharArray()).GetValue(7))
Dim a As String = tempRMACode.ToCharArray().GetValue(0)
Dim b As String = tempRMACode.ToCharArray().GetValue(7)
Dim c As Byte = Convert.ToByte(tempRMACode.ToCharArray().GetValue(0))
Dim d As Byte = Convert.ToByte(tempRMACode.ToCharArray().GetValue(7))
rmaValidationCode += String.Format("{0:X2}", temp8bit)
the output is:
temp8bit = 121 or 0x79
a = "A"
b = "8"
c = 65
d = 56
rmaValidationCode = "79"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…