Error in TypeOf Expression in VB->C#

1 posts, 0 answers
  1. Aleksander
    Aleksander avatar
    1 posts
    Member since:
    Nov 2011

    Posted 05 Jul 2013 Link to this post

    The following code produces the wrong C# code (if you convert back and forth you get a different meaning result):

    If Not TypeOf tmp Is String Then
        ' yadayada
    End If

    The C# produced is 
    if (!tmp is string) {
        // yadayada
    }

    Which probably doesn't even compile because you can't use ! on anything that could potentially be a string (might be mistaken about that though).
Back to Top