字符串阵列String[]皇牌天下投注网:转换为整型阵

来源:http://www.prospettivedarte.com 作者:计算机教程 人气:72 发布时间:2019-05-10
摘要:class Program { static void Main(string[] args) { Bq objBq = new Bq(); objBq.Input = "Hello Insus.NET"; byte[] Bytes = objBq.GetByte(); objBq.Byte = Bytes; MemoryStream ms = objBq.GetMemoryStream(); objBq.MemStream = ms; string output = obj
class Program
    {
        static void Main(string[] args)
        {
            Bq objBq = new Bq();
            objBq.Input = "Hello Insus.NET";

            byte[] Bytes = objBq.GetByte();




            objBq.Byte = Bytes;
            MemoryStream ms = objBq.GetMemoryStream();





            objBq.MemStream = ms;
            string output = objBq.GetString();


            Console.WriteLine(output);
        }
    }

在类中,添加一个方法,就是字符串转换为字符串阵列的方法:
皇牌天下投注网 1

皇牌天下投注网 2

 class Ae
    {
        private string _InputValue;
        private char _Delimiter;

        public Ae(string inputValue, char delimiter)
        {
            this._InputValue = inputValue;
            this._Delimiter = delimiter;
        }

    }
 class Bq
    {
        public string Input { get; set; }

        public byte[] Byte { get; set; }

        public MemoryStream MemStream { get; set; }

        public byte[] GetByte()
        {
            return Encoding.ASCII.GetBytes(Input);
        }

        public MemoryStream GetMemoryStream()
        {
            byte[] byteArray = Byte;
            return new MemoryStream(byteArray);
        }

        public string GetString()
        {
            StreamReader reader = new StreamReader(MemStream);
            return reader.ReadToEnd();
        }
    }
public void StringArrayToIntArray()
        {
            string[] stringArray = StringToStringArray();

            int length = stringArray.Length;
            int[] intArray = new int[length];

            for (int i = 0; i < length; i  )
            {
                try
                {
                    intArray[i] = Convert.ToInt32(stringArray[i]);
                }
                catch (Exception)
                {
                    // ...
                }
            }
        }

可以把字符串转换为MemoryStream。也可以把MenoryStream转换为字符串。

皇牌天下投注网 3皇牌天下投注网 4

 

Source Code

下面Insus.NET写了几个方法:

Source Code

 

string input = "3,7,2,8,1,9,1,34,67,78,22";

皇牌天下投注网 5皇牌天下投注网 6

 

 

皇牌天下投注网 7皇牌天下投注网 8

 

 

 

string[] stringArray = { "3", "7", "2", "8", "1", "9", "1", "34", "67", "78", "22" };

控制台测试以上的方法:
皇牌天下投注网 9

最后创建另外一个方法,就是字符串阵列转换为整型阵列:
皇牌天下投注网 10

Source Code

要处理为:

本文由皇牌天下投注网发布于计算机教程,转载请注明出处:字符串阵列String[]皇牌天下投注网:转换为整型阵

关键词:

最火资讯