How to add strings to a ienumerable<System.String>

Hi, I am trying to add arguments (strings) to a Systems.Collections.Generic.IEnumerable<System.String>. My ultimate purpose is to add this collection as a variable attachments for a Send Exchange Mail Message activity.
I have tried a loop to iterate through the folder + an invoke Method, however it did not work, as the “Add” is not part of IEnumerable.

Could you please help me here?

Thanks in advance!

IEnumerable is only to view the contents of a collection.
If you really want to add, convert the collection to List and then add items to the list.

if items is IEnumerable collection, for converting to list -

lstItems = items.ToList

Regards,
Karthik Byggari

1 Like

@Mogambo,

The IEnumerables are only for enumerating.
You can’t add item to them directly and you should add the item to it’s underlying source instead.

1 Like

Dear @sarathi125, thanks for the quick reply, you mean to create a list of strings, and then convert it to IEnumerable?

Could you please show me an example of what you mean?

Thanks so much!

@Mogambo,

No need to convert it. [ List<T> ] implements the [ IEnumerable<T> ] interface so it is already an enumerable.

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.