I have a Generic::List(String^)^ myList and some std::string & myValue values, and I need to check that the values are all contained in the list. (I don’t want to add values to the list).
What do I do in place of myList->Contains(myValue) to be sure I’m comparing the contents of the strings?
I know I can use InteropServices to marshal each element of the list.
I could convert the Generic::List to a cli::array if that would help!
Thanks
Melanie
From the
List<T>::Contains(T)documentation (C# documentation, but that doesn’t affect anything):This method determines equality by using the default equality comparer, as defined by the object’s implementation of the IEquatable.Equals method for T (the type of values in the list).
Because
String::Equals(String^)compares the contents of the strings, all that is necessary is converting thestd::stringto aSystem::String^. You can do that with amarshal_asand you should be good.