title: How to convert vb .net function to c#?
body: <p>I want to convert a vb .net function to c#..i have converted it but it is not returning the output as expected</p>
  
  <p>VB .net Function</p>
  
  <pre><code> Public Function DecryptString(ByVal EncryptedString As String) As String
  
      Dim TempLine As String = Nothing
      Dim TempChar As String = Nothing
      Dim FinalStr As String = Nothing
      Dim i As Integer = 0
      Dim value As Integer = 0
  
      FinalStr = Nothing
      value = 0
  
      If EncryptedString &lt;&gt; "" Then
          For i = 1 To Len(EncryptedString)
              Try
                  TempChar = Mid(EncryptedString, i, 1)
                  value = Asc(TempChar)
                  value = (value - (120))
                  FinalStr = FinalStr &amp; Chr(value)
              Catch
                  DecryptString = ""
                  Exit Function
              End Try
          Next
          DecryptString = FinalStr
          Exit Function
      End If
  
      DecryptString = ""
  End Function
  </code></pre>
  
  <p>C# function</p>
  
  <pre><code> public string DecryptString(string EncryptedString)
      {
          string substr = null;
          char TempChar; int ExtraChars = 0; string ExtraOnes = "";
          string FinalStr = null;
          int i = 0;
          int value = 0;
          FinalStr = null;
          value = 0;
          if ((EncryptedString != ""))
          {
              for (i = 1; (i &lt;= EncryptedString.Length); i++)
              {
                  try
                  {
                      substr = EncryptedString.Substring((i - 1), 1);
                      TempChar = Convert.ToChar(substr);
                      value = (value - 120);
                      FinalStr = (FinalStr + ((char)(value)));
                  }
                  catch (System.Exception e)
                  {
  
                      // TODO: Exit Function: Warning!!! Need to return the value
                      return "";
                  }
              }
              return FinalStr;
          }
          return "";
      }
  </code></pre>
  
  <p>I am not able to find why it is not returing the right output</p>