Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#字符串插值传递值_C#_String Interpolation - Fatal编程技术网

C#字符串插值传递值

C#字符串插值传递值,c#,string-interpolation,C#,String Interpolation,我在一个类中有一个只读字符串: public static class XssProtectionConstants { /// <summary> /// {0} specifies the report url, including protocol /// </summary> public static readonly string Report = "1; report={0}"; } 这引发了: Expected:<1

我在一个类中有一个只读字符串:

public static class XssProtectionConstants {
    /// <summary>
    /// {0} specifies the report url, including protocol
    /// </summary>
    public static readonly string Report = "1; report={0}";
}
这引发了:

Expected:<1; report=www.reportMyErrors.com>. Actual:<1; report={0}>. www.reportMyErrors.com
应为:。实际值:。www.reportMyErrors.com

如何更新断言以使其等于
“1;report=www.reportMyErrors.com>”

使用string.Format。更改字符串的代码是什么?您只是在附加它。请使用string.Format。更改字符串的代码是什么?你只是在附加它。
Expected:<1; report=www.reportMyErrors.com>. Actual:<1; report={0}>. www.reportMyErrors.com
Assert.AreEqual(_policyValue, string.Format(XssProtectionConstants.Report,"www.reportMyErrors.com" ) );