Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Converting a string into array of int
Message
 
À
26/11/2004 15:19:30
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00964997
Message ID:
00965051
Vues:
10
It Works!

Thanks.

>>I have a string:
>>
>>string s = "1,2,3,4,5";
>>
>>
>>and i need to convert each value into an int[]
>>
>>How can i do this ?
>>
>>Thanks.
>
>using System;
>class splittoints
>{
>   static void Main()
>   {
>     string s = "1,2,3,4,5,6";
>     string[] slist = s.Split(",".ToCharArray());
>     int[] nums = new int[slist.Length];
>     for(int i=0;i<slist.Length;i++)
>     {
>       nums[i] = Convert.ToInt32(slist[i]);
>       Console.WriteLine("String slice: {0}\tValue: {1}\tValueType:{2}",
>                         slist[i],nums[i],nums[i].GetType());
>     }
>   }
>}
>
Cetin
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform