PDA

Click to See Complete Forum and Search --> : What the freak does this mean


Cander
Mar 12th, 2002, 01:13 PM
packet.Data(i) = (Byte)'#'


???

i know what packet.Data(i) is ...but the (byte)'#'??

cant find anything on what that is....

kovan
Mar 12th, 2002, 01:31 PM
Originally posted by Cander
packet.Data(i) = (Byte)'#'


???

i know what packet.Data(i) is ...but the (byte)'#'??

cant find anything on what that is....

(byte) is a casting, i guess they call it boxing and unboxing in .net
in vb its done for you
for example

string number = "2344"
single number2 = number;

this is valid in vb
how ever in c# it has to be something like

string number ="2344";
int number2 = Convert.toInt32(number); OR int number2 = (Integer)number;

its converting the "#" to a byte datatype

Cander
Mar 12th, 2002, 01:37 PM
Ok I think I understand.

Lethal
Mar 13th, 2002, 07:42 PM
VB.Net doesn't allow implic conversion like this, unless Option Strict OFF is set.

Here is a VB example of the above code. It's called Literal Type Identifiers


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x As Object
x = 100I
MsgBox(x.GetType.ToString)
End Sub