A little improvement on AddTask()

I know this would be a rare case but atleast better than not fixing it. Currently in the AddTask() we only check with

string.IsNullOrEmpty(_taskText.value)

Still some can accidentally add some whitespaces and add the task down the list.

So an easy solution for this would be

private void AddTask()
{
    if (string.IsNullOrEmpty(_taskText.value) || string.IsNullOrWhiteSpace(_taskText.value)) return;
    // ...Code...
}
1 Like
private void AddTask()
{
    if (string.IsNullOrWhiteSpace(_taskText.value)) return;
    // ...Code...
}

This is sufficient. string.IsNullOrWhitespace includes empty

1 Like

Oh nice good to know :+1:

Privacy & Terms