in C Sharp by
Q:
Give an example of using sealed class in C#?

1 Answer

0 votes
by

Below is the sample code of sealed class in C# -

class X {} 

sealed class Y : X {}

Sealed methods –

class A

{

 protected virtual void First() { }

 protected virtual void Second() { }

}

class B : A

{

 sealed protected override void First() {}

 protected override void Second() { }

}

If any class inherits from class “B” then method – “First” will not be overridable as this method is sealed in class B.

Click here to read more about Loan/Mortgage
Click here to read more about Insurance

Related questions

+1 vote
+1 vote
asked Apr 9, 2020 in C Sharp by GeorgeBell
+1 vote
+1 vote
0 votes
asked Oct 18, 2019 in C Sharp by Robin
0 votes
asked Nov 4, 2020 in JSON by rahuljain1
0 votes
asked Nov 19, 2019 in Robotic Process Automation by rajeshsharma
0 votes
asked Feb 16, 2020 in C Sharp by rahuljain1
...