Friday, March 2, 2018

Tutorial 7 Methods in DotNet

What are Methods ?

Methods are normal functions which we need to create once and can be called multiple times. Its very common concept in NAV also. So we can define multiple functions.

But calling the method in Dotnet is very different and we need to follow certain rules while calling these methods and functions.

Why we need Methods ?

You can define it once and call it anywhere.

What are Static Methods and What are Instance Methods?

You might got surprised with syntax functions in Dotnet.

AccessModifier Static/or keep it blank ReturnType -FuntionName-(Parameters)

Access Modifier are E.g. Public , Private.

Static Function means you need not to create any instance of the class.
Non Static Function means you need to create instance of the class.



What are parameters and types of parameters in Dotnet?

In Dotnet, we have 4 types of parameters which we can define in methods or functions:

1. Valued Parameters :

These parameters are valued type means a copy of parameters is created inside and represented.
This concept is also common in NAV, we are using it regularly.


2. Reference Parameters :

Ref keyword is used in this case while passing parameters. This concept is also common in NAV.


3. Out Parameters :

Out Keyword is used when we need to pick multiple return type from a single function.
Like normally in NAV we can have only one type of parameters but using Out parameters we can have this achievable easily.


4. Params Parameters :

This type of Parameters we pass using params keyword and we can pass array also inside the argument.

This is also not present in NAV functions.




No comments:

Post a Comment