Is the order of elements on a C# List deterministic?

前端 未结 3 1120
[愿得一人]
[愿得一人] 2021-01-17 15:10

I\'ve always thought otherwise, but recently I had the need to know:

If I add elements to a list in a certain order, am I guaranteed to find then always on the same

3条回答
  •  离开以前
    2021-01-17 15:47

    Yes. List is an indexed collection; using Add() to put elements into the List will cause them to be indexed in the order they're added.

提交回复
热议问题