小编Jas*_*ang的帖子

类型'对象'上不存在属性

我有以下设置,当我循环使用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)

typescript

27
推荐指数
4
解决办法
7万
查看次数

Stream无法读取

我有下面的代码读取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)

c#

1
推荐指数
1
解决办法
1730
查看次数

这是什么"|" (管道)是指C#?

在Security Cryptography X509Certificates的上下文中,我在其中一个项目代码中遇到了这个问题.

X509Store store = new X509Store("MY", StoreLocation.CurrentUser);
store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadWrite);
Run Code Online (Sandbox Code Playgroud)

这是什么"|" 管意味着什么?

.net c# x509certificate2

-2
推荐指数
1
解决办法
72
查看次数

标签 统计

c# ×2

.net ×1

typescript ×1

x509certificate2 ×1