TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Paula
NA
3
0
String.Format and the Ampersand problem
May 11 2007 9:39 AM
I'm having a little issue with string.format and the use of composite formatting to build a little string.
Here is an example:
x is basically an invalid character, and amongst other things x could be an &
string
badString = x.ToString();
string error =
string
.Format(
@"The variable name has invalid characters: ""{0}""",
badString);
works fine if the invalid character is ! or " or £ well anything.... but the ampersand causes concatenation.
Example with a ^ as invalid character:
The variable name has invalid characters: "^"
With an ampersand:
The variable name has invalid characters: "" <----- I really want an & in there.
No matter what I try to do I just can't seem to get the "&" result.
I don't want to have to write an if statement to qualify what characters are in there if I can avoid it.
Thanks for your help :)
Reply
Answers (
2
)
XML Compatability
Could anyone explain.....