Ciao a tutti,
ho una funzione in C# che converte una variabile Byte in una String e la devo utilizzare in un progetto VB.NET, qualcuno sa dirmi se l'ho convertita correttamente?
Ma non è possibile utilizzare una funzione C# in progetto VB.NET?
Funzione in C#
codice:
public string byteToString(byte byIn)
{
byte byChkUpper, byChkLower;
char cChkUpper, cChkLower;
byChkUpper = (byte)(byIn / 16);
if (byChkUpper < 10)
{
cChkUpper = Convert.ToChar(byChkUpper + 48);
}
else
{
cChkUpper = (char)(byChkUpper + 55);
}
byChkLower = (byte)(byIn % 16);
if (byChkLower < 10)
{
cChkLower = Convert.ToChar(byChkLower + 48);
}
else
{
cChkLower = (char)(byChkLower + 55);
}
return "" + cChkUpper + cChkLower;
}
Funzione in VB.NET tradotta
codice:
Private Function byteToString(ByVal byIn As Byte) As String
Dim byChkUpper, byChkLower As Byte
Dim cChkUpper, cChkLower As Char
byChkUpper = byIn / 16
If (byChkUpper < 10) Then
cChkUpper = Convert.ToChar(byChkUpper + 48)
Else
cChkUpper = Convert.ToChar(byChkUpper + 55)
End If
byChkLower = Convert.ToByte(byIn Mod 16)
If (byChkLower < 10) Then
cChkLower = Convert.ToChar(byChkLower + 48)
Else
cChkLower = Convert.ToChar(byChkLower + 55)
End If
Return "" + cChkUpper + cChkLower
End Function
Ho un dubbio sulla riga "cChkUpper = (char)(byChkUpper + 55);" ovvero il "(char)" che fa? Converte in formato Char? Ho cercato sulla documentazione ma non ho trovato nulla...
Grazie a tutti