Linda Harrison
Linda Harrison

Reputation: 257

C++ -vector<string> in C#

I have a code in C++ as basically a class const and a dest

 Abc(vector<std::string>& names);
 virtual ~Abc();

I need to know the equilivalent in C#

Thanks

Upvotes: 0

Views: 984

Answers (1)

Sarfaraz Nawaz
Sarfaraz Nawaz

Reputation: 361342

in C#, you could just write this:

Abc(List<string> names);

and there is no use of ~Abc() in C#. It has garbage collector.

However, if your class manages resource, then derive Abc from IDisposable and implement Dispose() method which is somewhat similar to ~Abc():

class Abc : IDisposable
{
     Abc(ref List<string> names);
     void Dispose();       
}

Upvotes: 2

Related Questions