c# syntax

  • Thread starter Thread starter suzy
  • Start date Start date
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."
 
sText = string.Format("Hello my name is {0}. I am {1} years old.", "Suzy", 21)

HTH
fbhca
 
Back
Top