return empty List in catch block

Change this line:

return new List<string>emptyList(); // cannot compile

to:

 return new List<string>();

Passing a list as a refernce, and returning a boolean value from the function, it is a bad idea. Your method called getEmailAttachments, it's load attachments, and it should return attachments. If you want to check the result of loading attachments, i can suggest you return null and check the returned value.


Use

 return new List<string>();

I would take a slightly different approach. I would return an empty list but ALSO set the initial capacity to ZERO!

Like this:

return new List<string>(0);//notice the initial capacity to zero.

The reason is for memory consumption and optimization... I know it is a micro optimization but it won't hurt anything. It might actually benefit the overall application.


If someone still looking...

Use IEnumerable<string> as return type and:

return Enumerable.Empty<string>();