Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将字符串转换为字符串()VB.NET_Vb.net - Fatal编程技术网

将字符串转换为字符串()VB.NET

将字符串转换为字符串()VB.NET,vb.net,Vb.net,大家好,我不知道如何将列表中的值转换成String()格式 这是我当前的代码: Private files As String() files = New String() { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0A", "0B", "0C", "0D", "0E", "0F", "10", "11", "12", "13", "14"

大家好,我不知道如何将列表中的值转换成String()格式

这是我当前的代码:

 Private files As String()
files = New String() {
            "00", "01", "02", "03", "04", "05", "06", "07",
            "08", "09", "0A", "0B", "0C", "0D", "0E", "0F",
            "10", "11", "12", "13", "14", "15", "16", "17",
            "18", "19", "1A", "1B", "1C", "1D", "1E", "1F",
            "20", "21", "22", "23", "24", "25", "26", "27",
            "28", "29", "2A", "2B", "2C", "2D", "2E", "2F",
            "30", "31"}

Dim vals As New List(Of String)()
        Dim Counter As Integer
        For Counter = 1 To 5
            vals.Add(Counter.ToString)
        Next

        files = String.Join(",", vals) 'I'm getting an error here that I can't convert String to String ()

I want to finally bob this result: files = new String() {"1","2","3","4","5"}

谢谢大家的帮助。Join返回一个
字符串
VAL
已经是一个
列表(字符串)

如果需要
字符串()
,只需将列表转换为数组即可:

files = vals.ToArray()
…或首先避免创建列表:

files = Enumerable.Range(1, 5).Select(Function(x) x.ToString).ToArray()

String.Join
返回一个
String
VAL
已经是一个
列表(字符串)
。也许你想要
.ToArray()
。或者你想要什么?@mm8是的,我很清楚String.Join返回一个字符串,我怎样才能返回到array()?@mm8我有一个值计数器。Tostring(),这部分可以在字符串中取值吗?比如:files=Enumerable.Range(1.tostring(),5.tostring()).toArray()我不确定我是否遵循了<代码>可枚举。范围
接受两个
整数
。它不接受字符串。@mm8是的,我很清楚,但我在问题和您的回答中提到的文件字符串()是文件=integer@Mara您还可以对十六进制数组
Dim files=Enumerable.Range(0,50)执行类似的操作。选择(函数(x)x.ToString(“X2”)。ToArray()