Create a list from another list

前端 未结 4 1434
北海茫月
北海茫月 2021-01-04 05:23

Let\'s say I have:

class Plus5 {
    Plus5(int i) {
         i+5;
     }
}
List initialList = [0,1,2,3]

How I can create, from <

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-04 05:59

    Use LINQ to add 5 to each number in your list.

    var result = initialList.Select(x => x + 5);
    

提交回复
热议问题