C
C#Newbie
Ok I have this code in a function, but for discussion sake I will
revise it a little bit and make it shorter. The problem that I am
having is that trim does not work.
void main()
{
// message here is taken from a server and this is the string:
// start;
// a = 32, b = 33, c = 44;
// a = 33, b = 32, c = 55;
// end;
ParseMessage(Encoding.ASCII.GetString(message));
}
private void ParseMessage(string message)
{
string trimmedMsg = null;
string[] msgLine = null;
string[] msgItem = null;
char lineDelim = ';';
char itemDelim = ',';
char[] trimChar = {'='};
msgLine = message.Split(lineDelim);
foreach(string line in msgLine)
{
msgItem = line.Split(itemDelim);
foreach(string item in msgItem)
{
trimmedMsg = item.Trim(trimChar);
MessageBox.Show(trimmedMsg);
}
}
}
Please Help. Thank you
revise it a little bit and make it shorter. The problem that I am
having is that trim does not work.
void main()
{
// message here is taken from a server and this is the string:
// start;
// a = 32, b = 33, c = 44;
// a = 33, b = 32, c = 55;
// end;
ParseMessage(Encoding.ASCII.GetString(message));
}
private void ParseMessage(string message)
{
string trimmedMsg = null;
string[] msgLine = null;
string[] msgItem = null;
char lineDelim = ';';
char itemDelim = ',';
char[] trimChar = {'='};
msgLine = message.Split(lineDelim);
foreach(string line in msgLine)
{
msgItem = line.Split(itemDelim);
foreach(string item in msgItem)
{
trimmedMsg = item.Trim(trimChar);
MessageBox.Show(trimmedMsg);
}
}
}
Please Help. Thank you