Answered Questions

  • C# sealed variables

    I have taken a windows application and a button control in it.I want to declare a variable as a sealed and use that variable with in same class as we cannot use in other class. class test { public sealed int x = 5; public void abc() { MessageBox.Show(x.ToString()); } } class best :test { ...

    Sivavt

    • Mar 29th, 2012

    Keyword sealed can be used with class declaration to prevent it from being sub-classed.
    Keyword sealed can be used in method declaration to prevent it from being overridden.

    Rajeeva

    • Sep 4th, 2011


    To restrict users from inheriting the class by sealing the class using "sealed" keyword i.e. no class can be drieved from a sealed class. both Class and Method can be sealed, in that case Method cannot be overridden.