Posts

Showing posts from May, 2017

Group by the first letter of name Using LINQ

Image
Group by the first letter of name Using LINQ Program:                                List < String > names = new List < string >() { "Elizabeth" , "Mr Christian" , "James Stephens" ,      "Neal Sussman" , "Richard E" , "Peter Banes" ,                  "William Cook" , "Matthew D" , "Mark Dennis" , "Mrs Camilla Harrison" , "Robert" , "John Smith" }; var groupedNames = from n in names                    group n by n[0] into g                     orderby g.Key                     select new { FirstChar = g....

Overriding Vs Shadowing

Overriding Vs Shadowing Overriding changes implementation while shadowing replace the element with a completely new element only the interface vocabulary is same. class A     {         public virtual void Function()         {             Console .WriteLine( "A" );         }     }     class B : A     {         public override void Function() // Overriding         {             Console .WriteLine( "B" );         }     }     class C : B     {         public new void Function() // Sh...
If Base class have parameterless private Constructor, and Derived class have parameterless public constructor  can we create an object of Base Class/ Derived class?? Inheritance is possible??   class BaseClass     {         private BaseClass()         { }     }     class DerivedClass : BaseClass     {         public DerivedClass()         { }     } Answer: 'BaseClass.BaseClass()' is inaccessible due to its protection level
Question: What is the output of below program? class A     {         public virtual void Function()         {             Console .WriteLine( "A" );         }     }     class B : A     {         public override void Function()         {             Console .WriteLine( "B" );         }     }     class C : B     {         public new void Function()         {             Console .WriteLine( "C"...