0

i was used with php to use printf to build my strings, but i cannot find anything similar with asp and i end up writing crap like:

WrapTag="<"&Tag&">"&Text&"&nbsp;</"&Tag&">"

instead i would liek to write something more readable, like:

WrapTag=String.Format("<{0}>{1}</{2}>",Tag,Text,Tag)

as it was shown with this url: http://idunno.org/archive/2004/07/14/122.aspx but it is not working. Can anyone help me on that?

2
  • 1
    What is not working? String.Format should work just as you have posted without an issue. Commented Dec 14, 2011 at 10:29
  • 1
    Your code should work, please provide the error message. Note that you would only have to provide Tag once; String.Format("<{0}>{1}</{0}>", Tag, Text); Commented Dec 14, 2011 at 10:31

1 Answer 1

2

The code that you show is correct.

You don't have to send in the tag name twice, you can use the same value twice in the format:

WrapTag = String.Format("<{0}>{1}</{0}>",Tag,Text)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.