Methods Questions in C#

By
1. )  What are the elements used in a Method Declaration?                                         
  • Name of the Method
  • Type of value the Method returns ( type)
  • Lists of parameters
  • Body of the Method
  • Method Modifier(access-specifier)
2. )  What are the List of  Method Modifier in C#?                                                        
  • New
  • Public
  • Internal
  • Protected
  • Private
  • Static
  • Virtual
  • Abstract
  • Override
  • Sealed
  • extern
3. )  What is the Method Invoking in C#?                                                                        
The  process of activating  Method is known as invoking or calling. The Invoking is done using the dot operator as shown below:
Ex.
object Name.Method Name (actual-parameter-list);

4. )  What are the Method Parameters in C#?                                                                 

  • Value Parameters
  • Reference Parameters
  • Output Parameters
  • Parameter arrays
5. )  What is the Value Parameters in C#?                                                                       

The Value  Parameters are used to pass for passing parameters into method by value.
More details..

6. )  What is the Reference Parameters in C#?                                                               
Reference parameters are used to pass parameters into Method by reference.
More details..

7. )  What is the Output Parameters in C#?                                                                     
The Output parameters are used to pass results back to the calling Method.
More Details..

8. )  What is the use of  Parameter arrays in C#?                                                           
A Method that can handle variable number of arguments,is known as parameter arrays.Parameter arrays  are declared using the keyword param.

9. )  What is the Method Overloading in C#?                                                                  
To create More than one Method with same class name but with the different parameter lists and different definitions,is known as Method Overloading.
More Details..

10. )  What is the Main Method in C# and its use?                                                         
Every C# program starts execution from the Main Method.It has some properties which are given below:-
  • A Main Method is a static method of a Class .
  • It must have either Int or Void .
  • An Access-specifier Public is used as this method must be called from outside the program .
  • The Main Method can also have parameter which can receive values from the command -line.
 More Details..

1 comment:

Powered by Blogger.