Saturday, March 3, 2018

Tutorial 8 NameSpace in Detail

What is the Advantage of Namespace?

Namespace is code marking method to segregate code from different team and use of project demand. We can define multiple namespaces and define classes, methods and call it inside main function.


Alternative way to achieve Namespace using Project References?

We can define multiple namespaces in dotnet using class library and reference it in main project using reference option.

Then we can use namespace and functions from other class libraries also.



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.




Tutorial 6 Loop in Dotnet

1. While Loop

This Loop is checking the condition written in brackets , if the condition is correct then Code block will be executed till the While condition is fulfilled.

Note: While is similar to NAVISION IF condition.

2. Do While Loop 

do
{

}
while(Condition);

This loop will execute once and then checks the condition if condition is found true then do code will be executed again.

Note : This code is good for providing menu option to end user of program.

3. For Loop 

For Loop is also present in NAV and the working is same as in Dotnet. I had summarized the syntax for all loops present in Dotnet.

4. For Each Loop

This loop is present in dotnet and is very easy to use with collection classes in nav.

Break & Continue:

Break is a very special type of keyword that we can use in any loop to break on condition.

Continue is also same and is used for special reasons to continue a loop.