Is there a Linq method to add a single item to an IEnumerable?

后端 未结 11 642
感动是毒
感动是毒 2021-02-04 23:10

Basically I am trying to do something like this:

image.Layers

which returns an IEnumerable for all layers except the Parent layer,

11条回答
  •  独厮守ぢ
    2021-02-04 23:51

    Append and Prepend have now been added to the .NET Standard framework, so you no longer need to write your own. Simply do this:

    image.Layers.Append(image.ParentLayer)
    

    See What are the 43 APIs that are in .Net Standard 2.0 but not in .Net Framework 4.6.1? for a great list of new functionality.

提交回复
热议问题