Posts

Showing posts from March, 2013

How to use sealed keyword in .Net?

Image
Sealed is a keyword used to restrict inheritance future of programing language. When you mark any class to be sealed then you cannot make it to be parent class of other child class. In java final keyword is used for this same purpose. Example: namespace CA_Sealed {     // declare sealed class     public sealed class student ()     {         public void std()         {             Console .WriteLine( "This is sealed method" );         }     }     // here you cannot inherit properties of student class     class Program     {         static void Main( string [] args)         {             student obj = new student ();             obj.std();         }     } } Output : This is sealed method You cannot declare method to be directly sealed but Methods of only derived class can be made sealed with keyword sealed. Example : namespace CA_Sealed {     // declare sealed class     public   class student ()     {         public virtual void std()         {            

How to use Static keyword in .Net?, What is Static keyword in c.Net?

Image
Static is keyword. You can declare variable, method and class to be static, when you declare variable to be static then it is shares among all the object of this class as show in example. When you declare any variable or method to be static then you have no need to create class of this you can access directly by its name like "ClassName.VariableName" When you declare any class to be static then this class only contains static member and static methods. When you declare static method then it only use static variable (member) of this class. Example: namespace CA_Static {      class student     {         // define static variable that is shared         private static int member=0;                 public   void increment()         {             member++;         }         public static int getmember()         {             return member;         }     }     class Program     {         static void Main( string [] args)         {             student objstd = n

what is difference between Interface Inheritance and Implementation Inheritance in .net?

Image
  implementation inheritance Interface inheritance. When any class is derived from any other base class then it inherits all the properties and method of base class to derived class.  Its call implementation inheritance. When class inherits only signature of function from its corresponding base class is call interface inheritance. See Also : What is Class and Object in C#.net ? What is Encapsulation in C#.Net ? What is Abstract Class in C#.Net,How to use Abstract class in .net? Wht is Inheritance in c#.net ? What is Method Overloading in .Net?   Follow Me On Facebook -- /\/ir@\/  <(.'.)>

What is interface in .net? , How to use interface in .Net?

Image
The key word interface is use to define an interface. When you define interface you have not to define access modifier of any function (method) all method is public and in interface only declare method you cannot define method in interface. For Example: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CA_Interface {     class Program : student     {         public void print()         {             Console .WriteLine( "this is interface method" );         }         public static void Main( string [] args)         {             Console .WriteLine( "Hi........devlopers" );             Program obj = new Program ();             obj.print();         }     }     interface student     {         void print();     } } Some rule for Method Overriding : 1). you cannot define method in interface. 2). you cannot define variable in interface. 3). you have to define method in class which interties the interface. 4).

What is Polymorphisms in .Net?,How to use Polymorphisms in c#.net?

Image
 Polymorphism means to act as differently in different situation.it has wto type 1.    Methode overloading(satatic poly. Or compiletime poly. )       What is Method Overriding in.Net?, How to use Meth... 2.    Method overriding(dynamic poly. Or runtime poly.)        What is Method Overloading in .Net?,How to use Met... See Also : How to show hidden theme in win 7. How To Make "Star Design" In CMD Windows. How to get color name in C#.Net How to change Logon Message in Windows7 How to find the product Key of Windows XP CD   Follow Me On Facebook -- /\/ir@\/  <(.'.)>

What is Method Overriding in.Net?, How to use Method Overriding in.Net?

Image
In method overriding there is parent class has a method(function) with virtual keyword and this method is overridden in child class.as shown in example Example: namespace CA_Method_overriden {     class student     {         public int age;         public string name;         public virtual string mark()         {             return "35" ;         }     }     class girlstudent : student     {         public override string mark()         {             return "50" ;         }     }     class boystudent : student     {         public override string mark()         {             return "70" ;         }     }     class Program     {         static void Main( string [] args)         {             girlstudent objgs = new girlstudent ();             Console .WriteLine(objgs.mark());             boystudent objbs = new boystudent ();             Console .WriteLine(objbs.mark());         }     } } OUTPUT: 50 70 See Also : how

What is Method Overloading in .Net?,How to use Method Overloading in .Net?

Image
Method overloading means same mehtod name and same return type but number of parameter is defferant ,sequence of parameter may be also defferant.and also datatype of parameter is defferant. For Example: namespace CP_Method_overloading {     class A     {         public int sum( int a, int b)         {             return a + b;         }         public int sum( int a, int b, int c)         {             return a + b+c;         }         public double sum( int a, double b)         {             return a + b;         }     }          class Program     {         static void Main( string [] args)         {             A obj = new A ();             Console .WriteLine(obj.sum(10, 15));             Console .WriteLine(obj.sum(10, 15, 20));             Console .WriteLine(obj.sum(10, 71.52));         }     } } Output: 25 45 81.52 See Also : Android Installation for beginners_Part-1 Android Installation for beginners How to Resize a Partition in Windows 7 or Vista

Wht is Inheritance in c#,net,How to use Inheritance in C#.net

Image
•    Inheritance is main concept of OOP it show the parent child relationship between classes •    Inheritance is process in which one class get the properties and method from another class •    It's technic of deriving new class from old class.   Types of Inheritance: 1). Single Inheritance 2). Multilevel Inheritance 3). Multiple Inheritance 4). Hybrid Inheritance 5). Hierarchical Inheritance  1). Single Inheritance In single inheritance class B derived from class A 2). Multilevel Inheritance In multilevel inheritance class B is derived from class A and class c is derived from class B 3). Multiple Inheritance In multiple inheritance class C is derived from two class A and class B. This type of inheritance is not supported in c#.net 4). Hierarchical Inheritance In Hierarchical Inheritance Class B, class C and class D is derived from Class A. 5). Hybrid Inheritance In Hybrid inheritance Class B and C