C# > Modifiers > sealed Sealedmodifier prevents other classes from inheriting from it. Also you can use the sealed modifier on a method or property that overrides a virtual method or property in a base class. This enables you to allow classes to derive from your class and prevent them from overriding specific virtual methods or properties.
Examples 1. Sealed class classC1 { } sealedclassC2 : C1 { } classC3 : C2 { } // Error : cannot derive from sealed type C2
2. Sealed method
classA
{ protectedvirtualvoid F() { } protectedvirtualvoid F1() { } } classB : A { sealedprotectedoverridevoid F() { } protectedoverridevoid F1() { } } classC : B { protectedoverridevoid F() { } //Error cannot override inherited member because it is sealeD protectedoverridevoid F1() { } }
C# > Modifiers > const The const specifies that the value of the field or the local variable is constant and it cannot be modified. The const keyword differs from the readonlykeyword. A const field can only be initialized at the declaration of the field. A readonly field can be initialized either at the declaration or in a constructor.
C# > Types > int The int keyword is an integral type. Range: -2,147,483,648 to 2,147,483,647 Size: Signed 32-bit integer
Example: int i = 100; int x = 3.0; // Error 1 Cannot implicitly convert type 'double' to 'int'. An explicit conversion exists (are you missing a cast?) int y = (int)3.0; // OK: explicit conversion.
C# > Diagnostics > Stopwatch Stopwatch measures elapsed time. The Stopwatch measures elapsed time by counting timer ticks in the timer mechanism. If the installed hardware and operating system support a high-resolution performance counter, then the Stopwatch class uses that counter to measure elapsed time. Example: Stopwatch sw = newStopwatch(); sw.Start(); Thread.Sleep(500); sw.Stop(); TimeSpan ts = sw.Elapsed; MessageBox.Show("Elapsed time " + ts.ToString());