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

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


心有法竹
浏览 3130回答 3
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);}}}
打开App,查看更多内容
随时随地看视频慕课网APP