title: String Equals() method fails even though the two strings are same in C#?
body: <p>I want to compare whether two strings are equal or not in C# using the Equals() method of the string class. But even though both strings are same, my conditional check is failing.</p>
  
  <p>I have seen that both strings are equal and also verified this at the <a href="http://text-compare.com/" rel="noreferrer">http://text-compare.com/</a> site. I don't know what is the issue here...</p>
  
  <p>My code is :</p>
  
  <pre><code>protected string getInnerParaOnly(DocumentFormat.OpenXml.Wordprocessing.Paragraph currPara, string paraText)
          {
              string currInnerText = "";
              bool isChildRun = false;
  
          XmlDocument xDoc = new XmlDocument();
          xDoc.LoadXml(currPara.OuterXml);
          XmlNode newNode = xDoc.DocumentElement;
  
          string temp = currPara.OuterXml.ToString().Trim();
  
          XmlNodeList pNode = xDoc.GetElementsByTagName("w:p");
          for (int i = 0; i &lt; pNode.Count; i++)
          {
              if (i == 0)
              {
                  XmlNodeList childList = pNode[i].ChildNodes;
                  foreach (XmlNode xNode in childList)
                  {
                      if (xNode.Name == "w:r")
                      {
                          XmlNodeList childList1 = xNode.ChildNodes;
                          foreach (XmlNode xNode1 in childList1)
                          {
                              if (xNode1.Name == "w:t" &amp;&amp; xNode1.Name != "w:pict")
                              {
                                  currInnerText = currInnerText + xNode1.InnerText;
                              }
                          }
                      }
                  }
                if (currInnerText.Equals(paraText))
                {
                    //do lot of work here...
                }
     }
  }
  </code></pre>
  
  <p>When I put a break point in and go through step by step, watching each and every character, then there is a difference in currInnerText last index. It looks like an empty char. But I already used the Trim() function. This is the picture captured during the debug process.</p>
  
  <p>What is the solution for removing the empty char or any other spurious characters at the end of the currInnerText string?</p>
  
  <p><img src="https://i.stack.imgur.com/FXd9D.png" alt="enter image description here"></p>