Custom setter but auto getter [duplicate]

You need to use a backing field for your property. You’re getting a SO error because you’re recursively referencing your MyProp property in its own getter resulting in infinite recursion.

private short? _myProp;

public short? MyProp
{
    get
    {
        return _myProp;
    }
    set
    {
        if (value != null)
        {
            SomeProp = SomeWork(value);
            _myProp = value;
        }
    }
}

Leave a Comment

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