如何在 VB.NET 中拆分 [英] How to split in VB.NET

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

问题描述

我使用的是 VB.NET 代码.

I am using VB.NET code.

我得到了以下字符串.

http://localhost:3282/ISS/Training/SearchTrainerData.aspx

现在我也想用/"分割上面的字符串.我想将 SearchTrainerData.aspx 值存储在一个变量中.

Now I want to split the above string with "/" as well. I want to store the value SearchTrainerData.aspx in a variable.

就我而言

Dim str as String

str = "SearchTrainerData.aspx"

分割上述字符串并将其进一步存储在变量中的代码是什么?

What would be the code which will split the above string and further store it in a variable?

推荐答案

Split 函数接受字符,VB.NET 通过附加一个 'c' 到一个单字符字符串的末尾:

The Split function takes characters, which VB.NET represents by appending a 'c' to the end of a one-character string:

Dim sentence = "http://localhost:3282/ISS/Training/SearchTrainerData.aspx"
Dim words = sentence.Split("/"c)
Dim lastWord = words(words.length - 1)

这篇关于如何在 VB.NET 中拆分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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