Think you got a null reference exeption.
You did not declare your byte array on line 3:
Use something like this in C#:
byte[] Data = new byte[256];
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
You've declared a placeholder for the byte values (line 3), but didn't actually allocate them. Change it to byte[] Data = new byte[256]; .
No idea what Receive is supposed to do, so can't help you with that.
Momerath
Nearly a Senior Poster
3,384 posts since Aug 2010
Reputation Points: 1,232
Solved Threads: 558
Many options, have a look here: http://msdn.microsoft.com/en-us/library/f02979c7.aspx to convert a string to an int.
You could also use Convert it has among others the methods ToString and ToInt
Line 26 of your code could read: s = Data[i+1].ToString();
The assignment operator is = not :=!
In C# every type derives from Object, so you could even say something like MyStr = 123.ToString(); and MyStr would equal "123".
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
Well, look at the TryParse method here in the MSDN link I provided you in my previous post. There is some sample code.
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
for (int i = 0; i < textBox1.Text.Length, i++) {
Data[i] = textBox1.Text[i];
}
Momerath
Nearly a Senior Poster
3,384 posts since Aug 2010
Reputation Points: 1,232
Solved Threads: 558
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
Did you try to compile your code marked as unsafe?
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661