我有以下设置,当我循环使用for...of并获得属性"country"的错误时,类型"object"上不存在.这是循环遍历数组中每个对象并比较对象属性值的正确方法吗?
let countryProviders: object[];
export function GetAllProviders() {
allProviders = [
{ region: "r 1", country: "US", locale: "en-us", company: "co 1" },
{ region: "r 2", country: "China", locale: "zh-cn", company: "co 2" },
{ region: "r 4", country: "Korea", locale: "ko-kr", company: "co 4" },
{ region: "r 5", country: "Japan", locale: "ja-jp", company: "co 5" }
]
for (let providers of allProviders) {
if (providers.country === "US") { // error here
countryProviders.push(providers);
}
}
}
Run Code Online (Sandbox Code Playgroud) 我有下面的代码读取ftp响应流并将数据写入两个不同的文件(test1.html和test2.html).第二次StreamReader抛出一个stream was not readable错误.响应流应该是可读的,因为它还没有超出范围,并且不应该调用dispose.有人可以解释原因吗?
static void Main(string[] args)
{
// Make sure it is ftp
if (Properties.Settings.Default.FtpEndpoint.Split(':')[0] != Uri.UriSchemeFtp) return;
// Intitalize object to used to communicuate to the ftp server
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(Properties.Settings.Default.FtpEndpoint + "/test.html");
// Credentials
request.Credentials = new NetworkCredential(Properties.Settings.Default.FtpUser, Properties.Settings.Default.FtpPassword);
// Set command method to download
request.Method = WebRequestMethods.Ftp.DownloadFile;
// Get response
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
using (Stream output = File.OpenWrite(@"C:\Sandbox\vs_projects\FTP\FTP_Download\test1.html"))
using (Stream responseStream = response.GetResponseStream())
{
responseStream.CopyTo(output);
Console.WriteLine("Successfully wrote stream to …Run Code Online (Sandbox Code Playgroud) 在Security Cryptography X509Certificates的上下文中,我在其中一个项目代码中遇到了这个问题.
X509Store store = new X509Store("MY", StoreLocation.CurrentUser);
store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadWrite);
Run Code Online (Sandbox Code Playgroud)
这是什么"|" 管意味着什么?