Sunday, 21 July 2024

What is Method in c#

 

Class is blue print for the objects

Class contains variables and methods

Variables are used to store data.

Method is block of code to perform specific task ex: AddEmployee ,  deleteEmployee , SendMessage etc.

 

As Part of Method Concept, We have know about following components which involve method definition.






Main Components in Method Declaration

1.     Access Specifier          à Control Access

2.     Method Type               à Static or Instance

3.     Return Value Type     à Result value type or void (nothing to return)

4.     Method Name                          à User Specific

5.     Parameters                   à Input values to method

 

 

Types of Methods in C#

1.       Instance Methods

2.       Static Methods

3.       Extension Methods

4.       Abstract Methods

5.       Virtual Methods

 

Types of Return Values

·       Primitive Types

·       Reference Types

·       Void

·       Tuples

·       Task and Task<T>

 

Types of Parameters

·       Value Parameters

·       Reference Parameters (ref)

·       Output Parameters (out)

·       Parameter Arrays (params)

·       Optional Parameters

 

 


No comments:

Post a Comment

Thanks for the contribution, our team will check and reply back if response required.