I m working on a Multiplayer Poker card game. I have declared a static variable as
public static class GameInfo
{
public static string GameID;
}
to use its in multiple winforms. Similar to the the above declaration i have another varibale declared as
public static class LoginInfo
{
public static string UserID;
}
I have to send a game code to the server. when i use the following statement the client send the whole value of GameInfo.GameID at once.
GameInfo.GameID = "$POINT$" + LoginInfo.UserID + "#";
But the problem is that i need to select some text from listbox to send to the server. What i want to do is
GameInfo.GameID = "$POINT$" + listBox1.SelectedItem.ToString().Substring(16)+"#";
But when i use the server gets the value in parts. First it receives $POINT$+listbox selected text
and after that it send # and the further value.
The code i used to send the value to the server is
outStream = System.Text.Encoding.ASCII.GetBytes(GameInfo.GameID + LoginInfo.UserID + "#" + point);
serverStream.Write(outStream, 0, outStream.Length);
I tried to check the value of GameInfo.GameID (GameInfo.GameID = "$POINT$" + listBox1.SelectedItem.ToString().Substring(16)+"#";) by printing it in the same winform. But it does not append "#" chracter in the last. But when i send it to server it receives it as second part.
With GameInfo.GameID = "$POINT$" + LoginInfo.UserID + "#"; everthing works fine.
The problem arise when i use listbox1.SelectedItem.ToString();
private void button2_Click(object sender, EventArgs e)
{
if (listBox1.SelectedItem != null)
{
GameInfo.GameID = "$POINT$"+ listBox1.SelectedItem.ToString().Substring(16)+"#";
richTextBox1.Text = richTextBox1.Text + Environment.NewLine + GameInfo.GameID;
Form4 form4 = new Form4();
form4.Show();
}
else
{
label3.Text = "Please Select a Game";
}
}
This is the code i used to print the value of GameInfo.GameID. But is does not appends # character.
Ok say i m login by name xyz so LoginInfo.UserID has xyz the complete string would be
$POINT$xyz#
Now with ListBox i have an item "Game Created By xyz" so i extracted xyz by using substring function. But with this
GameInfo.GameID = "$POINT$"+ listBox1.SelectedItem.ToString().Substring(16)+"#";
# charcter is not appended.
The string i get is $POINT$xyz