OK, whats happening is that Split takes an array of chars which is not the ame thing as a string (although string can be converted to an array of chars via the ToCharArray() method. But then, you are only passing in a single char, so how does that work?
We the answer is in the full signature of Split which is (for the overload you are calling)
string[] Split( params char[]);
its the params keyword which does the magic (or rather the compiler does because of its presence). The compiler creates a char[] from the comma separated char params so
Split(',','-',' ');
would become an array of three chars that are passed to the Split method.
Regards
Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<
[email protected]>
I noticed this syntax works
string [] myArray = myString.split('.');
instead of
string [] myArray = myString.split(".");
I know the split method requires Char but what is really going on here
making the first line work not the second one?