Minas Mina
Minas Mina

Reputation: 2107

C++ Vector like class in C#

What is the analogous class of C++ std::vector in C#?

I want a class where it keeps an internal array inside and supports insertion at the back in O(1) time.

Upvotes: 9

Views: 14552

Answers (2)

Mulder2008
Mulder2008

Reputation: 181

  • std::list -> LinkedList ?
  • std::vector -> List ?

std::list is backed by array, each deletion would incur memory copy, same behavior as C# List. while C# LinkedList is backed by node list, same as std::vector.

so I believe below is correct.

  • std::list -> List
  • std::vector -> LinkedList

Upvotes: -3

Natan Streppel
Natan Streppel

Reputation: 5866

Here is a list with some C++ / C# containers that are roughly equivalent (not exact replacements) to each other:

Upvotes: 32

Related Questions