I have the following code;
char[] leadingDot = { '.' };
string trimStart = fileName.TrimStart(leadingDot);
I cannot seem to figure out the syntax to combine it into a single line. ReSharper has no suggestions either.
I completely understand why the following code doesn't work, let alone look right, but I would expect something like:
string trimStart = fileName.TrimStart( { '.' } );
It gives me the same vibe you get when you type var x = null; Ideas?
new char[] { '.' }char, you're making a newchar[].fileName.TrimStart('.'),filename.TrimStart('.', ':'), etc. There's an overload for one character, and an overloadTrimStart(params char[] trimChars)that takes either an array of char, or any number of single char arguments which will be treated as an array internally.new char[]. And then, in the new context, the syntax allows a different implication via theparamskeyword.