Error in coversion

2 posts, 0 answers
  1. atul
    atul avatar
    7 posts
    Member since:
    Apr 2011

    Posted 01 Dec 2011 Link to this post

    converter from to c# problem

    ToString in vb get converts to ToString.....though it should be ToString()

    For Example
    WSConnectionString = Security.Decrypt(notnothingStringXml(n).ToString)
    converts to
    WSConnectionString = Security.Decrypt(notnothingStringXml(n).ToString);
    though it should be
    WSConnectionString = Security.Decrypt(notnothingStringXml(n).ToString());

    other bizzare thing is
    Dim rndChr As Integer = (buffer1(i) Mod 87)
    converts to
    int rndChr = (buffer1(i) % 87);
    though it should be
    int rndChr = (buffer1[i] % 87);

  2. Todd
    Todd avatar
    66 posts

    Posted 04 Jan 2012 Link to this post

    Hello atul,

    Sorry for the trouble with your conversions. As it happens, there are a few cases where the open source NRefactory engine doesn't well handle the VB to C# conversion. One of those cases is trying to add "()" to C# when they're missing in VB. Technically, VB could also have the "()", so it's hard for the converter to predicatively add these characters. 

    The other challenge the syntax converter has is converting parenthesis to brackets. I think it's because the conversion engine doesn't fully understand your code (since it's not trying to compile it), so it doesn't know if the parens in VB are method calls or indexers. In VB parens can be both; in C#, parens are only for methods, and brackets are only for indexers.

    We'll investigate possible solutions to both issues, though. For now, expect to make some manual tweaks if your VB code covers either of these cases.


Back to Top