The accepted answer contains the statement:
You don't store hexadecimal values in strings.
Often this is true.
The domain of problems that lends itself to storing weird often non-printable characters a string, is rather small. But the jobs skill "integration" seems to be on the rise, and that is a place where you may want to do what the OP suggests.
If you are processing files, you may see that there is a custom set of characters that need to be ignored within the data.
In that case, storing non-printable characters (tab, escape, etc.) in a string can be the way to go.
I'll call these "ignored characters" white space even though a few in this example are printable, and the term white space often refers only to non-printable characters.
It is easier to write it that way.
For example you may have the requirement that the following are white space:
- space(0x32), tab(\t or 0x9), non-breaking space(0xA0), underscore(_), and dash(-)
but that these are not white space:
- new line, m-dash, and n-dash
That definition of white space will prevent you from using the built-in C# functions.
It will also prevent using most common libraries containing string functions (such as Extensions.cs).
readonly string whiteSpace = "\u0032\t\u00A0_-";
In this example you can use Contains against the preceding string to detect which characters are white space (using the definition given above or any other custom definition).
Loading those special characters into a string is an especially good choice if the users/business analyst have a history of changing the requirements during development and/or shortly before release.
(A string is easy to change, and requires minimal retesting against other systems)
I don't have permission to add a comment to the accepted answer, I guess because of its age. Given the increasing number of "integration" jobs which are appearing, this question and the point this answer makes are both relevant to a lot of developers today (15 years after it was asked).
'\u03A9'and'\x03A9'both print omaga (Ω) symbol on console output.