分割字符串,只得到第一个值 [英] Split string and get first value only

查看:886
本文介绍了分割字符串,只得到第一个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道是否有可能使用拆分到devide与用逗号分隔的多个部件,像这样的字符串:

 标题,流派,导演,演员

我只是想在第一部分中,每个字符串的标题而不是其他人呢?


解决方案

 字符串valueStr =标题,流派,导演,演员 
变种瓦尔斯= valueStr.Split(,)[0];



丘壑会给你的标题


I wonder if it's possible to use split to devide a string with several parts that are separated with a comma, like this:

title, genre, director, actor

I just want the first part, the title of each string and not the rest?

解决方案

string valueStr = "title, genre, director, actor";
var vals = valueStr.Split(',')[0];

vals will give you the title

这篇关于分割字符串,只得到第一个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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