简体   繁体   中英

Cast List Of JObject to List of .Net Object

how can we convert list of J Object into list of .net object ? i can do this with the help of like this

List<PriceSubject> lstPriceSubject = new List<PriceSubject>();

foreach (JObject obj in signalRInput.Input)
{
    PriceSubject price = obj.ToObject<PriceSubject>();
    lstPriceSubject.Add(obj);
}

but i want to do it in one line, is there any way to do it in one line ?

如果您输入的对象是JArray,则可以简单地执行以下操作:

List<PriceSubject> prices = signalRInput.ToObject<List<PriceSubject>>();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM