'ToArray' is not a member of 'String'

I found an example of code on the Internet that is designed to count the number of pages in a PDF file. However, I get the error message "ToArray is not a member of" String "on the following line:

Dim pdfMagicNumber() As Char = "0000".ToArray 

I am running VS 2010 in a Framework 2.0 project on a machine running Windows 7 and IIS 7. I found one article that talked about IIS configuration as the culprit of this error, but my settings seem to be consistent with what they recommended.

Any ideas on this error?

Thanks! Mike

+4
source share
1 answer

ToArray is an extension method introduced in .NET 3.5 on IEnumerable<T> . It works in .NET 3.5+ when calling string , since string implements IEnumerable<char> .

However, string.ToCharArray() is available in all versions of .NET, and even when you use .NET 3.5+, it will be more efficient than ToArray .

In other words, you want:

 Dim pdfMagicNumber() As Char = "0000".ToCharArray 
+7
source

Source: https://habr.com/ru/post/1414425/


All Articles