How to Prevent Concealment or Overriding in Public Property

I have an abstract base class that has a Property that I would like to prevent hiding, as well as new, and overriding.

public abstract class DomainObject
{
    public bool IsDeleted { get; set; }
}

public class BankAccount : DomainObject
{
    public bool IsDeleted { get; set; }
}

The problem is this: I need BankAccount to inherit from the DomainObject base class, so I cannot mark it as sealed, but I want to prevent the situation, override or new, IsDeleted at compile time.

+3
source share
4 answers

, : , . , , , "0108" " " = > "" = > " " = > " ".

, , โ€‹โ€‹ . , - " ", ...

+1

IsDeleted , . , , , sealed

public sealed override IsDeleted { get; set; }

new. new ,

+11

? , , .

+2

DomainObject, IsDeleted , DomainObject, ?

0

Source: https://habr.com/ru/post/1761341/


All Articles