如何将值传递给以 @ 开头的 C# 参数

本文关键字:开头 参数 值传 | 更新日期: 2023-09-27 18:34:36

试图传递值但没有进展。

场景:有一个公共常量字符串,如下所示。

public const string ImageFile = @"http://xyz.com/scom/{0}?type={1}&wid={2}";

然后,我将获得上述所需的 0,1,2 所需的相关值。

问题是如何将 0,1,2 的值传递给上面的常量字符串?

我的最终结果应该是这样的

string mySTring = "http://xyz.com/scom/123?type=jpg&wid=200"

请指教。

谢谢。

如何将值传递给以 @ 开头的 C# 参数

使用 String.Format

string ActualImageFile = String.Format(ImageFile, param1, param2, param3);
string.Format(@"http://xyz.com/scom/{0}?type={1}&wid={2}", param1, param2, param3);

应该做这个伎俩。