CSharp Methods

In CSharp, methods are a means of providing block of code that can be executed at any point in an application. The purpos of writing an method is to avoid writting repetated code for same output. You can create method that calculate the maximum value in an given array and use this method from any point in your code. This method can be thought of as containing reusable code.

Method have advantage of making your code cleane, readable and reusable, as the purpos of to keep related code together.

Defining and calling Methods

Usually, bellow syntax are used to define the method in CSharp

Syntax

  (parameter list)
{
   method Body comes here......
}

You can find various elements of method

Access specifire - Access specifire is used to determine the accessibility of method and can be public, private and protected.

Return Type - Method may return a value of specific type. Type can be any CSharp built in data type or custom data type. If method does not returning any values, then the return type is void.

Method Name - Method name is a unique identifier and it is case sensitive.

Parameters - Method may or may not be accept parameters. Parameter can be value type or reference type, the parameters are used to pass and receive data from a method.

Method Body - Method body contains group of related code which is responsible to perform an specific operation.



 
SHARE THIS IF YOU LIKE!
submit to reddit

SUBSCRIBE FOR LATEST UPDATES
HAVE WE CONNECTED ON FACEBOOK?
TOP TUTORIALSTOP CODE EXAMPLESTOP LIVE DEMOLINKSSTAY CONNECTED
HTML Tutorial
HTML5 Tutorial
Bootstrap3 Tutorial
Javascript Tutorial
TypeScript Tutorial
AngularJS Tutorial
CSharp Tutorial
PHP Tutorial
Developer Tools
Javascript
AngularJS
Google MAP API V3
ASP.NET
Javascript
AngularJS
Google MAP API V3
Contact Us
Advertise with Us
Privacy Policy
Disclaimer
Stay connected. We actually like you. If you want to get up to the minute updates, then connect with us on your fav below.
 
Twitter   Linkedin   Facebook   Google+    RSS   Pinterest
 
Protected by Copyscape Original Content Checker
 
 
Copyright ©2017 www.techstrikers.com Unauthorized reproduction/replication of any part of this site is prohibited.