Quantcast
Channel: SharpDevelop Community
Viewing all articles
Browse latest Browse all 1764

Double-parenthesis when converting from VB.Net to C#

$
0
0

Hello SharpDeveloper

I'm nearly too shy to post it, but although it is such a minor issue it gives me a lot of manual work:

Coming from a Java-background, I like to write VB code that includes parenthesis around an "if" clause or another statement where Java/C# requires parenthesis. When I now convert such VB code into C#, the parenthesis are doubled which is quite a bit tautologous, e.g. the following VB code:

 Public Sub SomeMethod(aValue As Int32)
  If (aValue < 10) Then
   DoSomething()
  End If
 End Sub

is converted into:

  public void SomeMethod(Int32 aValue)
  {
   if ((aValue < 10)) {
    DoSomething();
   }
  }

expected result:

  public void SomeMethod(Int32 aValue)
  {
   if (aValue < 10) {
    DoSomething();
   }
  }

Watch out when addressing this issue, the following conversion of course still needs double-parenthesis:

 Public Sub SomeMethod(aValue As Int32)
  If (aValue > 3) AndAlso (aValue < 10) Then
   DoSomething()
  End If
 End Sub

Does now and always must result in:

public void SomeMethod(Int32 aValue)
  {
   if ((aValue > 3) && (aValue < 10)) {
    DoSomething();
   }
  }

Best regards
C.


Viewing all articles
Browse latest Browse all 1764

Trending Articles