Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Converting a string into array of int
Message
De
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:
00965034
Vues:
11
This message has been marked as the solution to the initial question of the thread.
>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform