title: c# Find index of curly brace in string
body: <blockquote>
    <p><strong>Update:</strong> The code works, error was caused by something else.</p>
  </blockquote>
  
  <p>How do you find the index of a curly brace ({) in a string? I keep getting <code>-1</code> even though the curly brace is there. Here's my code;</p>
  
  <pre><code>var str = "example string with {brace}.";
  var index = str.IndexOf("{");
  </code></pre>
  
  <p>I've tried escaping the brace like this</p>
  
  <pre><code>var index = str.IndexOf("{{");
  </code></pre>
  
  <p>and like this</p>
  
  <pre><code>var index = str.IndexOf("{{}");
  </code></pre>
  
  <p>but it still returns <code>-1</code></p>