简体   繁体   English

如何将字符串拆分为数字?

[英]How to split a string into numbers?

How can I split the following string in C#? 如何在C#中分割以下字符串?

11213,334990829,2234,

I want to store each string (comma delimited) in a variable: eg 我想将每个字符串(以逗号分隔)存储在变量中:例如

Number1 = 11213
Number2 = 334990829
Number3 = 2234

Also, a max of 4 numeric strings would be present and if the string has less than 4 numeric strings than there will be a "," at the end of the string 另外,最多将出现4个数字字符串,并且如果字符串少于4个数字字符串,则字符串末尾将出现“,”

For eg: if there were two numeric strings, it would display 12121,43222, 例如:如果有两个数字字符串,它将显示12121,43222,

String[] numbers = "11213,334990829,2234,".Split(',');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM