Denis
Denis

Reputation: 344

String in String.Format({0:N}) Could not find any space inside string

I'm faced with the following problem - I format a string from a textbox

stringValue = String.Format(new CultureInfo("ru-RU"), "{0:N}",
                                                            result);

Everything seems OK, but when I try to find spaces inside this string, all methods return null or -1 like spaces are absent in the string, but numbers are split by spaces in my textbox! Why are the spaces not found? If I use any other string format - I could find any symbol in the string. What's the problem here? Who knows?

Upvotes: 0

Views: 238

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1502296

It's because there isn't a space, in terms of U+0020 (the normal ASCII space).

What you'll get in the output for the thousands separator is U+00A0, which is a non-breaking space. (At least, that's what I've seen.)

It's not clear what you're using this for, but perhaps you need to change your code to detect any whitespace rather than ' '.

Upvotes: 4

Related Questions