Question

I wrote VB.NET code like this:

d = Data.IndexOf("</a>", ("target='_top' class='ab1'>").Length() + s).

I want to write this in C#. When I wrote the above code in C#, it said there was an error with the Length keyword. How do I write the above code in C#?

Was it helpful?

Solution

You have an extra set of parentheses:

 d = Data.IndexOf("</a>", "target='_top' class='ab1'>".Length + s)

Try that

OTHER TIPS

Length is not a keyword in C# - it is either a property or an extension method on the object (like a string) that you are trying to manipulate.

So if it is a string you are using this will work:

myString.Length

(notice how the brackets are missing because it is a property).

Check this link out:

In it, you can easliy switch between C# to a VB good, to help you migrate:

http://msdn.microsoft.com/en-us/library/system.string.length.aspx#Y242

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top