我尝试过这几种方法,每次尝试时都会出错。
这是使用.net 3.5与asp.net(表格)和vb.net。
示例:
Dim _registrations = New List(Of Integer)
Dim regList As String
Dim ListOfReg = _registrations.convertall(Of String)(Function(i As Integer) i.ToString())
regList = String.Join(",", ListOfReg.ToArray())
错误讯息:
Overload resolution failed because no Public 'convertall' can be called with these arguments:
'Public Function ConvertAll(Of String)(converter As System.Converter(Of Integer,String)) As System.Collections.Generic.List(Of String)':
Argument matching parameter 'converter' cannot convert from 'VB$AnonymousDelegate_0(Of Integer,String)' to 'Converter(Of Integer,String)'.
其他尝试:
regList = String.Join(",", (_registrations.Select(Function(reg) reg.ToString()).ToArray()))
错误讯息:
Public member 'Select' on type 'List(Of Integer)' not found.
感谢任何帮助。
感谢。
答案 0 :(得分:15)
这应该有效,我想这是选择的方括号?
.NET 3.5解决方案
Dim integers As List(Of Integer) = New List(Of Integer)
integers.Add(1)
integers.Add(2)
integers.Add(3)
Dim commas As String = String.Join(",", integers.[Select](Function(i) i.ToString()).ToArray())
MessageBox.Show(commas)
以下是.NET 4.0解决方案
Dim integers As List(Of Integer) = New List(Of Integer)
integers.Add(1)
integers.Add(2)
integers.Add(3)
Dim commas As String = String.Join(",", integers.ToArray)
MessageBox.Show(commas)