如何拆分字符串 [英] How to split an string
本文介绍了如何拆分字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
i有122012字符串,我希望将此字符串拆分为字符串1 = 12和字符串2 = 2012.
我该怎么做。
解决方案
看看String.Substring
和/或String.Split
方法。
string Value =122012;
string s1 = Value.SubString(0,2);
string s2 = Value.SubString(2,4);
这只是编码为test获取需求的两个字符串
尝试在C#中使用Substring实例。
string str = 122014 ;
string s1 = str.Substring( 0 , 2 跨度>);
string s2 = str.Substring( 2 , 4 跨度>);
Hello,
i have string like 122012 and i want to split this string into string 1=12 and string 2=2012.
how can i do this.
解决方案
Take a look atString.Substring
and/orString.Split
method.
string Value="122012";
string s1=Value.SubString(0,2);
string s2=Value.SubString(2,4);
this is just coded for test to get two strings for the requirement
Try using Substring instance in C#.
string str = "122014"; string s1 = str.Substring(0, 2); string s2 = str.Substring(2, 4);
这篇关于如何拆分字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文