'Convert' Dictionary into List<object>

前端 未结 9 1962
感情败类
感情败类 2021-02-20 16:12

I have a Dictionary dictionary1 and I need to convert it into a List where Data has the properties lab

9条回答
  •  心在旅途
    2021-02-20 16:54

    I assume that "no loop" actually means "i want LINQ":

    List = dictionary1.Select(
        pair => new Data() {
            label = pair.Key,
            value = pair.Value
        })).ToList();
    

提交回复
热议问题