Funny Error

  • Thread starter Thread starter HardySpicer
  • Start date Start date
H

HardySpicer

Private Function GetInstalledVoices() As List(Of VoiceInfo)
'get the current cultureinfo
Dim currentCulture As CultureInfo = CultureInfo.CurrentCulture

'use linq to select each voiceinfo object from the
intalledvoices collection
Dim listOfVoiceInfo = From voice In speaker.GetInstalledVoices
(currentCulture) Select voice.VoiceInfo

'return the selected voiceinfo objects
Return listOfVoiceInfo.ToList(Of VoiceInfo)() ...... error
in this line
End Function

I get an error from the compiler

Error 1 Extension method 'Public Function ToList() As
System.Collections.Generic.List(Of TSource)' defined in
'System.Linq.Enumerable' is not generic (or has no free type
parameters) and so cannot have type arguments. C:\Users\hardy\Desktop\
Project\Vista Project\Form1.vb

This Function attempts to get all the voices from SAPI 5.3 to a combo
box.
This is the first part.

Hardy
 
At a cursory glance (and having to translate in my mind to C#?), I am not
100% sure what you are doing, but I am thinking you want to do something
more like this:

Dim listOfVoiceInfo As List(Of VoiceInfo) = From voice In
speaker.GetInstalledVoices() Select voice.VoiceInfo

Return listOfVoiceInfo



--
Gregory A. Beamer
MVP; MCP: +I, Se, SD, DBA

*************************************************
| Think outside the box! |
*************************************************
 
HardySpicer said:
Private Function GetInstalledVoices() As List(Of VoiceInfo)
'get the current cultureinfo
Dim currentCulture As CultureInfo = CultureInfo.CurrentCulture

'use linq to select each voiceinfo object from the
intalledvoices collection
Dim listOfVoiceInfo = From voice In speaker.GetInstalledVoices
(currentCulture) Select voice.VoiceInfo

'return the selected voiceinfo objects
Return listOfVoiceInfo.ToList(Of VoiceInfo)() ...... error
in this line
End Function

I get an error from the compiler

Error 1 Extension method 'Public Function ToList() As
System.Collections.Generic.List(Of TSource)' defined in
'System.Linq.Enumerable' is not generic (or has no free type
parameters) and so cannot have type arguments. C:\Users\hardy\Desktop\
Project\Vista Project\Form1.vb

This Function attempts to get all the voices from SAPI 5.3 to a combo
box.
This is the first part.

Hardy

The ToList method doesn't have any type parameter, as it doesn't do any
casting. It returns a list of the same type of elements as the object
that you call the method on contains, it can't return a list of any
other type.
 
Back
Top