300x250 AD TOP

helooo
Tagged under:

Methods


A method is a code block containing a series of statements. Methods must be declared within a class or a structure. It is a good programming practice that methods do only one specific task. Methods bring modularity to programs.
Advantages:
  • Reducing duplication of code
  • Decomposing complex problems into simpler pieces
  • Improving clarity of the code
  • Reuse of code
  • Information hiding
 characteristics :
  • Access level
  • Return value type
  • Method name
  • Method parameters
  • Parentheses
  • Block of statement
Example:


using System;
public class DF
{
    public void ShowInfo()
    {
        Console.WriteLine("This is Base class");
    }
}
public class DFSample
{
    static void Main()
    {
        DF df = new DF();
        df.ShowInfo();
    }
}



Example Of Method of Car class