Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. #region Commandline switch handling
  2. Dictionary<string, string> switchMap = new Dictionary<string, string>();
  3.  
  4. for (int i = 0; i < args.Length; i++)
  5. {
  6.     if (args[i][0] == '/' && args[i].Length > 1) //valid switch
  7.     {
  8.         int splitIndex;
  9.         if ((splitIndex = args[i].IndexOf(':')) > 1) //check if the switch has a value assigned to it
  10.             switchMap.Add(args[i].Substring(1, splitIndex - 1), args[i].Substring(splitIndex + 1));
  11.         else
  12.             switchMap.Add(args[i].Substring(1), string.Empty);
  13.     }
  14. }
  15. #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement