What does [param: NotNull] mean in C#?

When you mark method with NotNull it means, that method returns not null object:

[NotNull]
public object Get()
{
    return null; //error
}

When you mark setter it does the same – setter returns not null (because .net converts properties to get and set methods).

public virtual IRelationalTransaction Transaction { get; [NotNull] protected set; }

Equals to:

[NotNull] 
public virtual void set_Transaction(IRelationalTransaction value) { ... }

So, you need to add param: to point, that “i mean – parameter of setter is not null, not a result of set-method”:

public virtual IRelationalTransaction Transaction { get; [param: NotNull] protected set; }

Equals to:

public virtual void set_Transaction([NotNull] IRelationalTransaction value) { ... }

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)