Advertisement

using delimers

Started by December 09, 2005 01:00 PM
1 comment, last by GameDev.net 19 years, 2 months ago
here is my problem let me show you the code first

if(strMessage.IndexOf("<EOF>") > -1)
      {
		string delimStr = "<EOF>";
		char [] delimchar = delimStr.ToCharArray();
		mypacket = strMessage.Split(delimchar);
seems easy strMessage is my packet and im looking for "<EOF>" that is placed at the end of every packet, then I split the packet. mypacket is a string array so I add the split strMessage to mypacket. the problem is mypacket.lenght is 6. mypacket[0] = the data I need mypacket[1] - mypacket[5] = a empty string im guessing its placing 1 empty string per each character in my delimStr how can I remove these before placing the needed data into the mypacket array
you post is a little vague so it is difficult to give this a straight answer.

are you looking for a slick way to do this automatically?

if i were you, id just do something like

ArrayList mypacket = new ArrayList(strMessage.Split(delimchar));

mypacket.RemoveRange(1,mypacket.Count-1)


theres probably a slick way to do this, but your post is a little vague so it becomes a guessing game.

something like this might be what you're looking for (avoid the split completely and just grab everything up untill the EOF).

mypacket = strMessage.Substring(0,strMessage.IndexOf("<EOF>")
FTA, my 2D futuristic action MMORPG

This topic is closed to new replies.

Advertisement