【问题标题】:UTorrent Client Api c#UTorrent 客户端 API c#
【发布时间】:2017-09-23 14:44:51
【问题描述】:

我想使用“UTorrentClientApi”。在github上看到它:

https://github.com/latop2604/UTorrentClientApi

在 github 上他告诉我们如果要获取 Torrent 列表,我们必须使用这 3 行代码:

UTorrentClient client = new UTorrentClient("admin", "password");
var response = client.GetList();
List<Torrent> torrents = response.Result.Torrents;

我收到此错误:

无法将类型“system.collection.generic.IList”隐式转换为“System.Collections.Generic.List”。存在显式转换(您是否缺少强制转换?)

see my code

当我使用“var”时,我没有收到错误。但我看不到结果

See my Code

那么我能做些什么来解决这些问题呢?

【问题讨论】:

  • 不要发布代码链接,也不要发布代码图片 - 将相关代码直接插入您的问题中
  • 另外你想要(并且不显示在这个问题中)是加入列表的元素(例如:使用String.Join)而不是使用.ToString()
  • 在 Result.Torrents 之后添加 .ToList() 以从 IList 转换为 List

标签: c# utorrent


【解决方案1】:

你应该使用:

 List<Torrent> torrents = response.Result.Torrents.ToList();

这应该可以正常工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-25
    • 1970-01-01
    • 1970-01-01
    • 2012-02-02
    • 1970-01-01
    • 2017-04-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多