I am learning programming (self learning with online resources) and I came across this bit of code. I have hard time understanding it. I do not understand only last line OnItemAdded?.Invoke(this, item)
public async Task AddItem(TodoItem item)
{
await CreateConnection();
await connection.InsertAsync(item);
OnItemAdded?.Invoke(this, item);
}
I searched and read many resources (on MSN and here) and if I understand this correctly then this part of code checks if OnItemAdded
is not null, then this part of code is executed again? And OnItemAdded
is not null in case it failed to add item to list? Do I read and understand this line correctly?