It sounds like nextLine
is returning null
in some cases, so you need to think about how you want to handle it. For example:
string line = nextLine(clipboardText);
if (line == null)
{
// Nothing more to do.
return ...; // TODO: Work out what value to return
}
Clipboard.SetText(line);
clipboardText = removeFirstLine(clipboardText);
Alternatively, if your nextLine
method should never return null, then that indicates that it's got a bug.