나는 VB.NET으로 변환하는 C#에서 훌륭하게 작동하는 함수를 가지고 있습니다. 결과 집합을 VB.NET의 일반 목록으로 변환하는 데 문제가 있습니다.VB.NET에서 LINQ를 XML로 변환하여 일반 목록으로 만듭니다. 이상한 오류
코드는 (카테고리) .ToList 통해 결과를 변환 할 때
Public Function GetCategories() As List(Of Category)
Dim xmlDoc As XDocument = XDocument.Load("http://my_xml_api_url.com")
Dim categories = (From category In xmlDoc.Descendants("Table") _
Select New Category()).ToList(Of Category)()
Return categories
End Function
오류가 발생(). 오류 :
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.
범주는 내가 만든 간단한 개체이며 App_Code 디렉터리에 저장됩니다.
파일에 필요한 "Imports System.Collections.Generic"참조가 있으므로 결과 집합을 일반 목록으로 변환 할 수없는 이유가 표시되지 않습니다.
우수 포인트 및 +1입니다. 카테고리 개체에 값을 할당하는 섹션을 제거한 VB 변환기에 C#을 사용했습니다. 나는 그걸 다시 넣었고 모든 것이 잘되었다. 감사! –