Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在visual studio 2012中使用newton.jsoft(json.net)将c#翻译为vb.net时出现翻译错误_C#_Json_Vb.net_Linq_Json.net - Fatal编程技术网

在visual studio 2012中使用newton.jsoft(json.net)将c#翻译为vb.net时出现翻译错误

在visual studio 2012中使用newton.jsoft(json.net)将c#翻译为vb.net时出现翻译错误,c#,json,vb.net,linq,json.net,C#,Json,Vb.net,Linq,Json.net,此代码有什么问题: 在visual studio 2012中使用newton.jsoft(json.net)将c#翻译为vb.net时出错: 原始代码: public static List<TradeInfo> GetTrades(BtcePair pair) { string queryStr = string.Format("https://btc-e.com/api/2/{0}/trades", BtcePairHelper.ToString(pai

此代码有什么问题: 在visual studio 2012中使用newton.jsoft(json.net)将c#翻译为vb.net时出错: 原始代码:

 public static List<TradeInfo> GetTrades(BtcePair pair)
    {
        string queryStr = string.Format("https://btc-e.com/api/2/{0}/trades", BtcePairHelper.ToString(pair));
        return JArray.Parse(WebApi.Query(queryStr)).OfType<JObject>().Select(TradeInfo.ReadFromJObject).ToList();
    }
错误:

“公共共享函数ReadFromJObject(o为Newtonsoft.Json.Linq.JObject)为TradeInfo”的参数“o”未指定错误1参数

被调用函数(vb):

首先,C代码返回一个字典,而VB代码返回一个列表。其次,这两种方法具有不同的参数数量和类型。我没有超出这个范围。

我认为您只需要一个“AddressOf”,因为您实际上没有调用“ReadFromJObject”:

Public Shared Function GetTrades(ByVal pairlist() As BtcePair, Optional ByVal limit As Integer = 150) As Dictionary(Of BtcePair, List(Of TradeInfoV3))
    Dim tradeInfoListReader As Func(Of JContainer, List(Of TradeInfoV3)) = (Function(x) x.OfType(Of JObject)().Select(AddressOf TradeInfoV3.ReadFromJObject).ToList())
    Return MakeRequest(Of List(Of TradeInfoV3))("trades", pairlist, tradeInfoListReader, New Dictionary(Of String, String)() From {{ "limit", limit.ToString() }}, True)
End Function

IIRC,您需要
AddressOf
。您的C#和VB版本根本不相似-您是以什么方式将一个转换为另一个的?Slaks的在线工具是正确的,它构建得很好。我马上就要考试了。
Public Shared Function ReadFromJObject(o As JObject) As TradeInfo
    If o Is Nothing Then
        Return Nothing
    End If

 Return New TradeInfo() With 
  {.Amount = o.Value(Of Decimal)("amount"), _
    .Price = o.Value(Of Decimal)("price"), _
    .[Date] = UnixTime.ConvertToDateTime(o.Value(Of Long)("date")), _
    .Item = BtceCurrencyHelper.FromString(o.Value(Of String)("item")), _
    .PriceCurrency = BtceCurrencyHelper.FromString(o.Value(Of String)
    ("price_currency")), _
    .Tid = o.Value(Of Long)("tid"), _
    .Type = TradeInfoTypeHelper.FromString(o.Value(Of String)("trade_type")) _
    }
End Function
Public Shared Function GetTrades(ByVal pairlist() As BtcePair, Optional ByVal limit As Integer = 150) As Dictionary(Of BtcePair, List(Of TradeInfoV3))
    Dim tradeInfoListReader As Func(Of JContainer, List(Of TradeInfoV3)) = (Function(x) x.OfType(Of JObject)().Select(AddressOf TradeInfoV3.ReadFromJObject).ToList())
    Return MakeRequest(Of List(Of TradeInfoV3))("trades", pairlist, tradeInfoListReader, New Dictionary(Of String, String)() From {{ "limit", limit.ToString() }}, True)
End Function