title: How to replace substring in a string in c#
body: <p>I want to replace the substrings 134 and 1254 in a string </p>
  
  <pre><code>((startTime==134)&amp;&amp;(endTime==1254))
  </code></pre>
  
  <p>with some dynamic value - say, for example, 154 and 1234 respectively. 
  I have written the code to place using <code>String.Split</code> method but it seems the code is very long. How can I make it shorter and more robust? </p>
  
  <p>Here is the code:</p>
  
  <pre><code>string s = "((startTime==134)&amp;&amp;(endTime==1254))";
  string[] time = s.Split(')').Reverse().ToArray();
  var start = time.FirstOrDefault(s =&gt; s.Contains("startTime")).Split('=')[2];
  var end = time.FirstOrDefault(e =&gt; e.Contains("endTime")).Split('=')[2];
  start ="154";
  end = "1234"
  time[3] = "((startTime=="+start;
  time[2] = "&amp;&amp;(endTime=="+end;
  string joinedstring;
  joinedstring= String.Join(")", time.Reverse());
  </code></pre>