I am given a collection of elements Lazy. Then I want to forcibly “create” them all in one go.
void Test(IEnumerable<Lazy<MailMessage>> items){
}
Typically, with an element, the Lazycontained object will not be created until one of its members is available.
Having seen that there is no method ForceCreate()(or similar), I am forced to do the following:
var createdItems = items.Where(a => a.Value != null && a.Value.ToString() != null).Select(a => a.Value);
Used ToString()to create each item.
Is there a more accurate way to force the creation of all elements?
source
share