Ive got an array of (string) player names that exist in my masterAdmiServer. I need the masterAdminServer to send the names to the player so the player can check to see if the name they entered is a registered username. I know how to send a single string over the network, but I need to send string Names; to the players. Ive tried it several different ways and get a variety of errors. C#
Hey…we can’t send an array over network, thats why we are having collections, try to send an Object of collection like List, Set… Thanks
Make your array a single string by concatenating them all in one:
void SendArray(string[] str)
{
StringBuilder sb = new StringBuilder("");
foreach(string s in str)
{
sb.Append(s+"_");
}
string newString = sb.ToString();
// Send your string over the network
}
Then you can retrieve on the other side:
string [] SplitToArray(string str)
{
return str.Split('_');
}