为了账号安全,请及时绑定邮箱和手机立即绑定

c#中如何将一个string数组转换为int数组

c#中如何将一个string数组转换为int数组

C#
心有法竹 2019-04-04 02:02:20
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);

}
}
}


查看完整回答
反对 回复 2019-04-05
  • 3 回答
  • 0 关注
  • 3118 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信