这是常量类:
public static class Constants
{
public const string USER_ID = "conduent";
public const string PASSWORD = "593becd1-02f6-46f0-bf34-25b393ad041b";
public static readonly Uri BASE_URI = new Uri("https://staging.test-476b.com");
public static readonly Uri GET_TOKEN_URI = new Uri("api/session");
public static readonly Uri SEND_CASE_URI = new Uri("api/referral_request");
}
这是用法
public class DanestreetHttp
{
private AuthToken authToken = null;
private readonly HttpClient httpClient = new HttpClient()
{
BaseAddress = Constants.BASE_URI
};
}
在屏幕截图上,您可以看到错误,在我更改BaseAddress = Constants.BASE_URI
为BaseAddress = new System.Uri("https://staging.test-476b.com")
. 静态只读初始化有什么问题?
屏幕
PS。我目前的解决方案:BaseAddress = new Uri(Constants.BaseAddress)