[tip] string.Split(',') - Jon Galloway

[tip] string.Split(',')

Why bother with

myString.Split(new Char[] {','})
when you can type
myString.Split(',')

I felt dumb for having missed this, but all the sample code I've seen since then (including on MSDN) always uses the new Char[] {','} syntax.

Thanks, Scott, for correcting my previous post complaining about this syntax.

Published Thursday, March 11, 2004 10:48 PM by Jon Galloway
Filed under:

Comments

# re: [tip] string.Split(',')

A party of one ;)

I had an almost argument with Bill Wilkinson about this on aspmessageboard.com

He was reciting the doc (and intellisense) but I had been passing ',' for months.

Friday, March 12, 2004 8:53 AM by AndrewSeven

# re: [tip] string.Split(',')

String.Split uses the param keyword, so behind the scenes it's still creating the array for you.

Thursday, March 18, 2004 11:53 PM by Shannon C

Leave a Comment

(required) 
(required) 
(optional)
(required)