Monday, December 21, 2020

New From c# 9.0 (1 part )

 Hello , 

I can't write for a long time because of the intensity work.  

In my new article , I will talk abbout new features from c# 9.0.  New feature are available that make our business easier. 


1-Target-typed new expressions

If the object type can be estimated when creating an object, it will no longer be necessary to specify the type before calling constructor. For example :


List<string> list =new List<stirng>();


Here, since the type of object can be estimated from the defination on the left side, it will be possible to use as follows.

List<string> list=new();

2-Prameter null checking

Null control of parameters that will be passed to methods that will be added to the end of the parameter ! it can now be done automatically with the mark.

For example : 


public void Work (Person person)

{

  if (person == null)

  {

       thrpw new ArgumentNullException(nameof(person)));

   }

}

In this way, instead of checking null, we can make this process automatic by defining it as follows.


public void Work(Person perso !)

{

}

 




No comments: