c# winform如何将下面数字转换为数组? 我有一个变量里面存了类似下面的一些字符,string numAll = "100,200,300,400,500,"(即每个数字之间以","隔开)我想把numall中的数字放到一个数组中,该如何实现呢?最好能提供下代码,多谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string numAll = "100,200,300,400,500,"; string[] numAllList = numAll.Split(','); 都是整形的话,看需要可转换一下int.Parse(str); // example: str="100";Convert.ToInt32(str); split函数就可以了!上面的已经说的很明白了! 多谢大大们,最后在问一个傻傻的问题..如果将刚才生成的string数组中的值全部转为int[]数组呢?多谢了。 string[] numAllList=numAll.Split(',');...int[] nums=new int[numAllList.Length];for (int i=0; i<nums.Length; i++) { nums[i]=Convert.ToInt32(numAllList[i]);} 按上面的分,还可以按如下转换。未测试.....string[] arrs = new string[] { "100", "300", "200" };int[] arri = Array.ConvertAll<string, int>( arrs, delegate( string s ) { return int.Parse( s ); } ); string numAll = "100,200,300,400,500,"; string[] numAllList = numAll.Split(','); int[] nums=new int[numAllList.Length]; for (int i=0; i <nums.Length; i++) { nums[i]=Convert.ToInt32(numAllList[i]); C#开发XML模版维护工具 3个窗体form, 如何实现tab的效果? c# 初学者 压缩加密->下载->解压解密->运行,如何防止解压后的临时文件被拷贝 求一简单的正则表达式!! ★★ 如何修改CheckedListBox 选定项对应的文本值 我做一个网站,想以最快得速度打开首页,而首页上有七处要查询数据库并显示,有什么方法可以减少首页打开时间? 怎样将汉字转化为GBK内码? source label控件透明的问题! 急!(大家来看看) [原创]友人的提醒 谢谢! 之作为一个初学者 或是一个菜鸟程序员! 怎样生产没有debug信息的程序?
string[] numAllList = numAll.Split(',');
int.Parse(str); // example: str="100";
Convert.ToInt32(str);
如果将刚才生成的string数组中的值全部转为int[]数组呢?
多谢了。
...
int[] nums=new int[numAllList.Length];
for (int i=0; i<nums.Length; i++) {
nums[i]=Convert.ToInt32(numAllList[i]);
}
未测试.....
string[] arrs = new string[] { "100", "300", "200" };
int[] arri = Array.ConvertAll<string, int>( arrs, delegate( string s ) { return int.Parse( s ); } );
string numAll = "100,200,300,400,500,";
string[] numAllList = numAll.Split(',');
int[] nums=new int[numAllList.Length];
for (int i=0; i <nums.Length; i++) {
nums[i]=Convert.ToInt32(numAllList[i]);