Is there a reason for this? I am asking because if you needed to use lots of empty chars then you get into the same situation as you would when you use lots of empty strings.
Edit: The reason for this usage was this:
myString.Replace ('c', '')
So remove all instances of 'c's from myString.
You could use nullable chars.
If you don't need the entire string, you can take advantage of the delayed execution:
You can even combine multiple characters...
... and only the first 7 characters will be evaluated :)
EDIT: or, even better:
and its usage:
In terms of C# language, the following may not make much sense. And this is not a direct answer to the question. But fowlloing is what I did in one of my business scenario
The
null
andwhite space
had different business flows in my project. While inserting into database, I need to insertempty string
to the database if it is white space.the same reason there isn't an
int.Empty
. Containers can be empty. Scalar values cannot be. If you mean 0 (which is not empty), then use'\0'
. If you meannull
, then usenull
:)There's no such thing as an empty character. It always contains something. Even '\0' is a character.
OK, this is not particularly elegant for removing letters, since the .Replace method has an overload that takes string parameters. But this works for removing carriage returns, line feeds, tabs, etc. This example removes tab characters: