Shortcut for creating character array

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...

Answers


Especially for multiple elements, the following shortcut is nice:

";".ToCharArray()

You can use this with multiple chars:

";,\t".ToCharArray()

In C# 3, you can use an implicitly-typed array:

new[] { ';' }

If you're not passing a StringSplitOptions, you can simply take advantage of the params parameter:

.Split(',')

Need Your Help

"ImportError: No module named twilio.rest"

python twilio

I have installed python 2.7.10 with PATH access and correctly installed twilio. However, when I try to execute a code I get this error message

How to use DecimalFormat to format money?

java android decimalformat

The input looks like 8.7000000 and I want to format it to look like 8.70 EUR.