Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to return a list of strings in C#

Tags:

c#

visual-c++

com

Can anybody tell me How to store and return List of Strings.

I am asked this Because i have written a function which returns Collection of strings and I want to prepare a COM for that one and need to consume that COM(to get the returned list ) in VC++ where I can extend some functionality using that list of strings. I hope this would be clear.

like image 297
Cute Avatar asked Nov 29 '22 20:11

Cute


1 Answers

List<string> or string[] are the best options.

Here is a sample method that returns list of strings :

public static List<string> GetCities()
{
  List<string> cities = new List<string>();
  cities.Add("Istanbul");
  cities.Add("Athens");
  cities.Add("Sofia");
  return cities;
}
like image 132
Canavar Avatar answered Dec 05 '22 07:12

Canavar