3

I've this Piece of code:

  public class Tag : ValueObjectBase
    {
        public virtual string Name { get; set; }

        public virtual bool IsDeleted { get; set; }

        public virtual long Count { get; set; }

        public virtual DateTime CreationTime { get; set; }

        protected override void Validate()
        {
        }

and I just inherit the NewsTag class from Tag like this:

 public class NewsTag : Tag
    {
        public NewsTag(string name, int count)
        {
            Count = count;
            Name = name;
        }

        protected override void Validate()
        {
            throw new NotImplementedException();
        }
    }

why Does Resharper suggest me to make the NewsTag class as sealed??

Ehsan
  • 816
  • 9
  • 27
  • why it should suggest you ? what is the point of making nested class sealed ? – Selman Genç Feb 02 '14 at 18:19
  • @Selman22: The same as making any other class sealed... although there's no indication that it's nested, as far as I can see. – Jon Skeet Feb 02 '14 at 18:21
  • @JonSkeet I mean what is special about nested class ? in order to keep nested class count simple in the inheritance chain? – Selman Genç Feb 02 '14 at 18:26
  • 1
    @Selman22: I don't understand - the question didn't mention nested classes, so why did you introduce them into the conversation? There's very little that's particularly different about them, other than that they can be private. – Jon Skeet Feb 02 '14 at 18:29
  • @JonSkeet sorry I mean inherited class :)) I'm just confused,I'm trying to figure out what is the reason of making an inherited class sealed – Selman Genç Feb 02 '14 at 18:32
  • @Selman22: *Every* class you write inherits from something, if you think about it. The point of sealing a class derived from one of your other classes is the same as sealing any other class: design for inheritance or prohibit it. – Jon Skeet Feb 02 '14 at 18:41
  • @JonSkeet I just removed the virtual keyword and it didn't suggest anymore! but I can't find out the reason of that – Ehsan Feb 02 '14 at 18:45
  • @JonSkeet you right.but OP write "why **Does't** Resharper suggest" and I though it doesn't suggest and he wants a custom suggestion that's why I'm confused,I guess it was just a typo:) – Selman Genç Feb 02 '14 at 18:47
  • @JonSkeet oh god! I'm so so sorry about the type mistake, just edited it, "why does resharper suggest to make it seald? " – Ehsan Feb 02 '14 at 18:50

0 Answers0