VB.NET String.Split方法? [英] VB.NET String.Split method?

查看:862
本文介绍了VB.NET String.Split方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用String.Split方法时遇到一些问题,示例在这里:

I'm having some issues using the String.Split method, Example here:

Dim tstString As String = "something here -:- URLhere"
Dim newtstString = tstString.Split(" -:- ")
MessageBox.Show(newtstString(0))
MessageBox.Show(newtstString(1))

以上内容以PHP(我的母语!)将在此处返回内容,并在消息框中返回URL。

The above, in PHP (my native language!) would return something here AND URLhere in the message boxes.

在VB.NET中,我得到:

In VB.NET I get:

something here

AND

: (colon)

String.Split仅适用于标准字符吗?我似乎无法弄清楚这一点。我确定这很简单!

Does the String.Split only work with standard characters? I can't seem to figure this one out. I'm sure it's something very simple though!

推荐答案

这是您需要做的,以防止字符串被转换到 Char 数组。

This is what you need to do, to prevent the string from being converted to a Char array.

    Dim text As String = "something here -:-  urlhere"
    Dim parts As String() = text.Split(New String() {" -:- "}, StringSplitOptions.None)

这是在这种情况下需要使用的 System.String 成员函数

This is the System.String member function you need to use in this case

Public Function Split(ByVal separator As String(), ByVal options As StringSplitOptions) As String()

这篇关于VB.NET String.Split方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆