例把
string[] str=new string[]{1,2,3,4}
转换为int[] str=new int[]{1,2,3,4}????

解决方案 »

  1.   

    楼主string数组里面的1234应该加上""吧
      

  2.   

    不好意思,呵呵,上面的字符串数组写错了
    string[] str=new string[]{“1”,“2”,“3”,“4”}
    输入法不对,不过也就是这个意思
      

  3.   


    string[] str = new string[] { "1", "2", "3", "4" };
            int[] a = new int[str.Length];
            for (int i = 0; i < str.Length; i++)
            {
                a[i] = int.Parse(str[i]);
            }
      

  4.   

    不知道这样满足了你的要求没有?
    using System;
    using System.Collections.Generic;
    using System.Text;namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {            string[] str = new string[4];            int[] s = new int[4];            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);
            }
        }
      

  5.   

    sorry  ,, 大意了大意了,,,不好意思