Shortcut for creating character array

Daniel Mošmondor picture Daniel Mošmondor · Jul 22, 2012 · Viewed 26k times · Source

Since I like to Split() strings, I usually use

new char[] { ';' }

or something like that for a parameter for Split().

Is there any shortcut for creating a character array with one element at compile time? Not that I mind typing, but...

Answer

usr picture usr · Jul 23, 2012

Especially for multiple elements, the following shortcut is nice:

";".ToCharArray()

You can use this with multiple chars:

";,\t".ToCharArray()