c#中如何将一个string数组转换为int数组
3 回答
饮歌长啸
TA贡献1951条经验 获得超3个赞
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string[] str = new string[10];
int[] s = new int[10];
Console.WriteLine("请输入十个字符串");
for (int i = 0; i < str.Length; i++)
str [i]= Console.ReadLine();
for (int i = 0; i < str.Length; i++)
s[i] = Convert.ToInt32(str[i]);
int a=0;
for (int i = 0; i < str.Length; i++)
a += s[i];
Console.WriteLine("a={0}" , a);
}
}
}
- 3 回答
- 0 关注
- 3167 浏览
添加回答
举报
0/150
提交
取消