i have an array of Tag objects
class Tag
{
public string Name;
public string Parent;
}
i want code to return a list of the tag names as an array of strings
i have an array of Tag objects
class Tag
{
public string Name;
public string Parent;
}
i want code to return a list of the tag names as an array of strings
To best use IEnumerable interface. Otherwise you can use linq queies for that or basic foreach loop
var names = from t in tags
select t.Name;
Something like this will give you an IEnumerable over names, just use .ToArray()
if you wan't array of those.
I assume that you want something like this :
public List<string> GetNamesOfTag(List<Tag> tags)
{
List<string> Name = new List<string>();
foreach(Tag item in tags)
{
Name.Add(item.name);
}
returns Name;
}