typical “typo” for VB developers using C#

Someone who sat in on my C# for VB programmers session at Code Camp emailed with a little problem. DataSet.Table(“myTable”) was throwing the error

Error: ‘System.Data.DataSet.Tables’ denotes a ‘property’ where a ‘method’ was expected

It is such a common mistake we VB people make in C# because those parens are just totally second nature to us! Even I had to think about it a minute before I saw the problem! It’s

DataSet.Table[“myTable“]

The funny thing was seeing a C# programmer complaining that in VB, everything is parens and it makes it hard to tell if we are referring to a parameter or an element, making a method call or getting info out of an array/collection. Great perspective!


http://www.AcehAid.org

  Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!  

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.