2
Answers

Split a String to Byte Array

Ask a question
DGilbert

DGilbert

20y
5.6k
1
I have a string that contains an IP address. I am trying to split that based upon the "." into a byte array so I can loop through the range of IP addresses. I can convert on the loop itself, but this seems to be a slow way. My code looks like this.... string [] bStartAddress = null; bStartAddress = strTempAddress.Split(new Char [] {'.'}); I have tried... bStartAddress = Convert.ToByte(strTempAddress.Split(new Char [] {'.'})); but I get an error message that says I cannot convert a byte to a byte. Please excuse my ignorance if there is an easy solution, I am a VB programmer trying to make my way to C#. VB will implicitly convert a string to a byte on the fly, so I never had to deal with this. Thanks in advance for any suggestions.

Answers (2)