views:

53

answers:

1

i now have experience working on both asp.net and php. asp scores on the integration and rich set of outofbox features and the power of C#. However after using php for some time, i came across a nifty feature in it which i desire to be there in asp.net

in php we can use the variables like this

$bar = "My name is $bar and my pet's name is $pet_name";

if we had to do the same thing in asp.net using c# i may have to write

string str - "my name is " + bar + " and my pet's name is " + pet_name

assuming bar and pet_name are already declared, can't there be a feature where i can denote variables like php does and don't have to be bothered by appending multiple strings?

+8  A: 

You could use String.Format()

string s = string.Format("My name is {0} and my pet's name is {1}",bar,pet_name);
Philippe Leybaert
yeah it seems likely. but it still doesn't match the simplicity of php. Any further luck?
Anirudh Goel
Use a template parser. (http://www.stringtemplate.org or http://viciproject.com/wiki/projects/parser/home or http://nvelocity.sourceforge.net/)
Philippe Leybaert