代码之家  ›  专栏  ›  技术社区  ›  Anirudh Goel

我能做什么?$bar=“我的名字是$bar”;在asp.net中使用C#?

  •  2
  • Anirudh Goel  · 技术社区  · 17 年前

    我现在有asp.net和php的工作经验。 asp在集成和丰富的开箱即用功能以及C#的强大功能方面得分。然而,在使用php一段时间后,我发现其中有一个漂亮的特性,我希望它能出现在asp.net中

    在php中,我们可以使用如下变量

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

    如果我们必须在asp.net中使用c做同样的事情,我可能不得不编写

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

    1 回复  |  直到 17 年前
        1
  •  8
  •   Philippe Leybaert    17 年前

    string s = string.Format("My name is {0} and my pet's name is {1}",bar,pet_name);