Saturday, March 3, 2018

Tutorial 10 Static and Instance Members in Dotnet Classes

What are Static Members ?

Static members of a class are defined once in a definition and are assigned with keyword static. It simply means this variable is static variable. It will be put as a separate copy and anyone can point it.

What are Instance Members ?

Instance Members are normal variables and method which will keep as a copy.

Why we need both and what is the use of these members?

Static members will reduce the time of execution and save  memory by keeping only one copy of variable to point.

As class is concept of OOPS and our NAV is based on objects so there will be no concept of these members.

Lets see some example for reference :


Hope this part is understandable with this post if not kindly comment.

Tutorial 9 Classes and its components

What are Classes ?

Classes are collection of Data Types and methods. in Simple terms we can say a Class is a Codeunit of NAV and inside codeunit we can define multiple variables called datatypes and functions as we normally do in NAV.

As per need , we have codeunit type : Single Instance Codeunit and many events are introduced from NAV 2016. Like the same, we have multiple types of classes in dotnet. Lets see all now :

With Classes we come to following terms to understand :

1. Constructor 

Constructors are basically used to initialize class object / data types in dotnet

2. Destructor

This is used for cleaning the variables and in new versions of dotnet it is not required to define. It is done with tilt sign before class name. 

3. Overloading of Constructor 

We can define multiple constructors based on parameters for one class and these are basically termed as overloading.

Dotnet itself create on constructor for us when we define a class.
Constructor have same name as class and no return type.

Note please Dont mug up , just try and learn the use.

4. this Keyword

this keyword is pointing to the objects or variables defined in classes.

So lets have one screenshot for reference :






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.