'dr' is a 'variable' but is used like a 'method'

Posted by Blake on 2/8/2012

I wonder if the quotes were added around those those as a sarcastic ‘emphasis’. Anyway, this is a common error that Visual Studio will toss when Visual Basic programmers are writing C# code. ;) It’s one of those syntax differences between the two languages that takes a few weeks to untrain yourself on. Mine happened to be while using a data reader so I thought I would share the difference for anyone Googling.


    Dim buf As String = dr("id")


    string buf = dr["id"].ToString();