Right now I am working on a project where I am converting a VB.NET code to C#. I have used https://converter.telerik.com/, which I have heard is quite accurate. Which it mostly is, but now I have approached a error: non-invocable member 'dataset.tables' cannot be used like a method.
This is my first converting ever so I have it quite hard to see what is wrong with just this line of code.
Heres the VB.NET sample:
RcdCount = da.Tables("pubs").Rows.Count.ToString()
Here is the C# sample:
RcdCount = da.Tables("pubs").Rows.Count.ToString();
As you can see, the only change that is made is the ";" at the end. How do I solve this?
CodePudding user response:
As it seems, Tables
is an indexer, therefore square brackets must be used:
RcdCount = da.Tables["pubs"].Rows.Count.ToString();
CodePudding user response:
I see you already found the answer you were looking for. But if you still want to take a look, I tested the code sample on this site and it translated correctly.