C#,一个字符串的 Split() 方法 [英] C#, a String's Split() method

查看:36
本文介绍了C#,一个字符串的 Split() 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C#,String 的 Split() 方法,如何将结果 string[] 放入 ArrayList 或 Stack?

C#, a String's Split() method, how can I put the resulting string[] into an ArrayList or Stack?

推荐答案

您可以使用数组(或任何其他实现 IEnumerable 的对象)初始化 List).与 ArrayList 相比,您应该更喜欢强类型的 List.

You can initialize a List<T> with an array (or any other object that implements IEnumerable). You should prefer the strongly typed List<T> over ArrayList.

var myList = new List<string>(myString.Split(','));

这篇关于C#,一个字符串的 Split() 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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