public class BaseEx { protected internal int xyz=10; } public class Derived : BaseEx { public string RetrunData() { return xyz.ToString(); } } public class MainClass{ Derived obj = new Derived(); Console.WriteLine("data:{0}",obj.RetrunData()); }
interface IExample{ public void funExample(); //Error: The modifier 'public' is not valid for this item. string fun2(string strParam1, string strParam2);//no error }
Class parent{ public virtual void fun_overridable(){//some code here} } class child:parent{ public override void fun_overridable(){//some code here} }
namespace TestNamespace{ private class testClass{ } }
abstract class abstractExample{ public abstract void func1(); } class derivedClass : abstractExample { public override void func1(){ //your code here..... } }
abstractExample objAbstract=new abstractExample();//error in this line.
public class example{ public const int i = 20; i=30;//compile time error. public readonly int j=20;//initialized at declaration. public readonly int l; public example(){ l=30;//readonly field initialized in constructor also. } }
sealed class exampleSealed{ //code of a class. } class derived : exampleSealed{ //error can not inherit from exampleSealed }
public struct struct1 { } public class class1 : struct1 //Error : 'class1': cannot derive from sealed type 'struct1' { }