C#中的字符串插值传值
C# string interpolation pass value in
我在 class 中有这个只读字符串:
public static class XssProtectionConstants {
/// <summary>
/// {0} specifies the report url, including protocol
/// </summary>
public static readonly string Report = "1; report={0}";
}
我想访问它并传入一个值,使其现在等于 "1; report=www.reportMyErrors.com"
用于此单元测试断言:
Assert.AreEqual(_policyValue, XssProtectionConstants.Report );
这抛出:
Expected:<1; report=www.reportMyErrors.com>. Actual:<1; report={0}>. www.reportMyErrors.com
如何更新我的断言以使其等于 "1; report=www.reportMyErrors.com>"
?
Assert.AreEqual(_policyValue, string.Format(XssProtectionConstants.Report,"www.reportMyErrors.com" ) );
我在 class 中有这个只读字符串:
public static class XssProtectionConstants {
/// <summary>
/// {0} specifies the report url, including protocol
/// </summary>
public static readonly string Report = "1; report={0}";
}
我想访问它并传入一个值,使其现在等于 "1; report=www.reportMyErrors.com"
用于此单元测试断言:
Assert.AreEqual(_policyValue, XssProtectionConstants.Report );
这抛出:
Expected:<1; report=www.reportMyErrors.com>. Actual:<1; report={0}>. www.reportMyErrors.com
如何更新我的断言以使其等于 "1; report=www.reportMyErrors.com>"
?
Assert.AreEqual(_policyValue, string.Format(XssProtectionConstants.Report,"www.reportMyErrors.com" ) );