c# syntax

S

suzy

hello,

i have seen places where the following syntax similar to the following is
used:

param={0}, sParam

where {0} is replaced by sParam.

How can I do that with string concatenation. I want to simplify the
following command:

sText = "Hello my name is " + sName + ". I am " + nAge + " years old."

to something like:

sText = "Hello my name is {0}. I am {1} years old."
 
G

Guest

sText = string.Format("Hello my name is {0}. I am {1} years old.", "Suzy", 21)

HTH
fbhca
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top