C# Parser of strings with list of assignments
I'm not sure exactly where to start with reviewing this code. There are many things that jump out as unsafe or awkwardly approached.

If my source string contained:

foo1=bar1 foo=bar


Then querying for 'foo'

int startPos = s.IndexOf("=", s.IndexOf(varName)) + 1;


Will incorrectly return the index of 'bar1' not 'bar'. 

Use positional data to locate the keys within the string. All keys begin immediately after a space, and end immediately before an equals sign, and contain no spaces or equal signs. 

Start by splitting the string on the '='. Your first key will be result[0]. Find the last index of a ' ' character in result[1]. Everything before that is your first value. Iterate your split results to build a Dictionary&lt;string, string&gt; and a Dictionary&lt;string, string[]&gt;, processing the value of key as appropriate based on the assignment type. You can then check if a particular key is defined by looking for it in the dictionaries, and get the value directly.

Is there a purpose to specifying the number of array elements in the key, when you already know the number from the value? How do you propose resolving the difference in the case of an incorrectly constructed string?

"a[1]= x y z"


Should either be a[3]= x y z or a[1]= x, but which takes precedence. If you can control the incoming format, and are not dealing with something beyond your control, use a[]= x y z and don't rely on the count being placed in the key.