Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Sealed
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { //public sealed class ParentClass // Error: cannot derive from sealed type 'Rextester.ParentClass' public class ParentClass { public virtual int Method1(int a) { Console.WriteLine(a); return a; } public virtual string Method2(string Name) { Console.WriteLine("Parent Class Sealed Method : " + Name); return Name; } } //public class ChildClass : ParentClass --> We Can't inherit sealed class. we get above error. public class ChildClass : ParentClass { public int Method1(int a, int b) { Console.WriteLine(a*b); return a*b; } //public override string Method2(string Name) //don't restrict public override sealed string Method2(string Name) { Console.WriteLine("Parent Class Sealed Method : " + Name); return Name; } } public class Tclass: ChildClass { public override string Method2(string Name) { Console.WriteLine("Third Class Sealed Method : " + Name); return Name; } } public class Program { public static void Main(string[] args) { //Your code goes here Console.WriteLine("Hello, world!"); ChildClass cc=new ChildClass(); ParentClass pc=new ParentClass(); Tclass tc=new Tclass(); cc.Method1(2,5); cc.Method1(1000); // Call Parent Class Method1 Method. pc.Method2("Chanti"); //Without Sealed Parent Class Method : Chanti cc.Method2("Chinna"); //Without Sealed Parent Class Method : Chanti tc.Method2("Chandu"); //With Sealed , cannot override inherited member 'Rextester.ChildClass.Method2(string)' because it is sealed tc.Method2("Chandu"); // Without Sealed Modifier, Third Class Sealed Method : Chandu } } }
run
|
edit
|
history
|
help
0
C# programming exercise 2
enum extension
Intuit // C# // Lecture_4 // Laba_#2
Test DateTimeStyles.AdjustToUniversal
DateTime With TimeZone to UTC DateTime
http://codegolf.stackexchange.com/questions/82526/sum-it-up-with-a-digital-triangle C# solution
orytitoyt
Using Events/Delegates to Subscribe To A Service - Emails
test code
1