Salve a tutti,
avrei qualche dubbio sul metodo split, su internet ho trovato il seguente esempio:
codice:
class TestStringSplit
{
static void Main()
{
char[] delimiterChars = { ' ', ',', '.', ':', '\t' };
string text = "one\ttwo three:four,five six seven";
System.Console.WriteLine("Original text: '{0}'", text);
string[] words = text.Split(delimiterChars);
System.Console.WriteLine("{0} words in text:", words.Length);
foreach (string s in words)
{
System.Console.WriteLine(s);
}
}
}
che dovrebbe dare il seguente output
codice:
Original text: 'one two three:four,five six seven'
7 words in text:
one
two
three
four
five
six
seven
non mi raccapacito però come ha fatto a separare one da two e come ha fatto ad eliminare la t di troppo, perchè il primo separatore che indica è lo spazio. Forse è un errore di battitura?
Altra cosa che volevo chiedere è a me nella stringa ci saranno o parole, più che altro sigle del tipo "s_02" o date in formato data+ora o numeri. C'è qualche funzione del tipo "isdate" o del tipo "isinteger" o "isstring" ?
La stringa che andrò a dividere è questa:
codice:
~22/07/1987 10:00:00#2#s_00#100#54#78#87#85#174#54#65#6#5#s_01#25#26#25#24#20~
e a seconda di cosa c'è scritto ,che sia una data, un intero o una stringa dovrò andare a salvare ovviamente le informazioni in una variabile apposta.
Vi ringrazio in anticipo,
Neptune.