enmity4 enmity4 - 1 year ago 98
C# Question

Combining args in C#

I'm trying to create a command using a game framework which doesn't support the use of quotes to create arguments with spaces.
I tried to merge every separate argument after the first to make a final string to use but I can't figure out what I'm doing wrong:

case "add":
client.SendToClient(PluginUtils.CreateNotification(client.ObjectId, 8453888, "Logged to console"));
string FullArgs = "";
for (int i = 1; i == args.Length; i++ )
FullArgs = FullArgs + args[i];
Console.WriteLine("[Anti-Spam] " + FullArgs + " added to filter list");

To clarify I'm using array index 1 to begin with because 0 is already part of the command, so anything 1 and beyond I would like to combine into a string.

I'm not getting any errors and just getting a blank output, can anyone please help or even suggest a better way? Greatly appreciated :)

Answer Source

Guessing it should be:

for (int i = 1; i < args.Length; i++ )
  FullArgs = FullArgs + args[i];

If args.length is > 1, it will never populate FullArgs

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download