Question: Suppose a simple example where a method retrieves a collection (such as a list containing some configuration strings) and tries to examine it in some way:

```
void Init()
{
    XmlDocument config = new XmlDocument();
    config.Load(someXml);
    var list = config.SelectNodes("/root/strings/key"); // Normally, list should not be null or empty

    if (list == null || list.Count == 0)
        throw new SomeExceptionType(message);   // What kind of exception to throw?

    // Iterate list and process/examine its elements
    foreach (var e in list) ...
}

```

In this specific instance, the method cannot continue normally if nothing was retrieved. I'm unsure what exception type to throw in such situations. My options are, as far as I know:

* throw nothing manually and let `NullReferenceException` be thrown
automatically (which doesn't handle empty list situation),
* throw custom exception type (probably not a good idea, as I don't anticipate the caller will try to do anything about the exception,
i.e. he won't be looking for a speecific exception type to handle),
* do something else?

Answer: 
You can create your own exception type for appropriate logic:

```
public class InitializationException : Exception
{
}

```

and then:

```
throw new InitializationException {Message = "Collection is empty"};

```
That not much of programming problem as it's a design issue, the reason .NET list object don't throw exceptions when they are empty is because there is a lot of cases where a empty list is an expectable and acceptable situation. 

If in the context the list you work with is never supposed to be empty then throw an exception (a custom one)

If however it's possible and logical that list may be empty, why interrupt the whole thing, it's excepted not exceptional, so need for an exception ? A `foreach` loop and an empty list won't throw an exception, the loop simply won't loop.

As for the null possibility (quite rare for `SelectNodes` if understand well) it's same issue, in some libraries or functions returning a `null` is a normal behavior not an exception.