DotNET Schools

Blogs & Tutorials for Microsoft.NET and Leading web Technologies

NULL Conditional Operator In C# 6.0

Sometimes developers get the following exception: “object reference not set to an instance of an object”. Whenever we got such type of exception our mouth fell open but in C# 6 we can handle it easily using NULL Conditional Operator. So we can handle “System.NullReferenceException” using this operator. I am going to explain it with a very simple example where I am handling NullReferenceException for string datatype.

Null-Conditional operator (?.) Read More

C# 8.0 - Experimenting With Non-Nullable Reference Type Using Visual Studio 2017

Nullable Reference Type is one of the most popular upcoming features of C# which may be released with C# 8.0. However, since C# 8.0 has not been released yet and the development is going on, so till the final release, its behavior may be a little bit different than the current behavior explained in this article.

Many discussions are going on in developer’s communities about C# 8.0 Nullable reference type, and most of us are referring it to a breaking change. However, in my opinion, it is a significant change but not a breaking change. Read More >>

C# 7.2 - In Parameter And Performance

In C# 7.2, “in parameter” has been introduced which allows passing read-only reference of a variable. Before C# 7.2, we used “ref” and “out” keywords for passing the references of a variable. “Out” is meant for output only whereas ‘ref’ is meant for input and output both. However, if we had to pass a read-only reference, i.e., passing a variable as input only, then there was no direct option for that. So, in C# 7.2, “in parameter” has been introduced for this purpose. Read More >>

Resource Optimization (Bundling And Minification) Boost Your Website Performance

To load your website faster you must do the resource optimization. There are a lot of reasons we need resource optimization. I mean to say the optimization of number of requests sent from your browser and data served by the server. We can do the resource optimizations in many ways and it is not limited to Bundling, Minification & Sprite Images, we can do a lot of other optimization too.

These are the 3 popular concepts of resource optimization:

  1. Bundling (Bundling of .js,.css, .resx, .html…)
  2. Minification (Minification of .js, .css,.html…)
  3. Sprite (Image Sprite) 

Expression - Bodied Methods in C# 6

In C# 6 Microsoft introduces a new feature Expression-bodied Methods which is very similar to and inspired by anonymous lambda expression. But there are some differences between these two.

In case of Expression-bodied methods it must have return type, name and returned expression.

We can use access modifiers (private, public, protected, internal and protected internal) with expression-bodied method. We can declare it as virtual, static or it can also override its parent class method. It can be asynchronous if it is returning void. Read More >>

Using NULL Conditional Operator With Indexes

NULL conditional operator or NULL propagation operator was introduced with C# 6.0 and you will find dozens of blogs and articles on NULL conditional operator. I have also written some articles on it and following is a link for the same but I have noticed that very few people are using all the benefits of NULL conditional operator.

NULL Conditional Operator In C# 6.0

In this blog, I am going to present those hidden gems for you.  Read More >>

Using Static Preferences and Conflicts: C# 6 And C# 7

This blog explains that if we are including “using static” as directive in C# 6 or C# 7 i.e., “Using types instead of namespaces as directive,” and you have a local method with the same name as that of “using static” in that case how to resolve conflict and which method will get preferences.

As we know, before C# 6 we used to include only namespaces as “using directive.” But in C# 6 & C# 7 we can include static classes, enum, non-static classes & structs too as “using directive.” So in C# 6 & C# 7, we can include following types as "using directive".  Read More >>

ng-app Directive in AngularJS

ng-app directive is used to define AngularJS application. We can use this to auto-bootstrap an AngularJS application. It designates the root element of AngularJS application and generally kept near <body> or <html> tag. We can define any number of ng-app directive inside the HTML document but only one AngularJS application can be bootstrapped automatically (auto-bootstrapped) the other applications needs to be bootstrapped manually.  Read More >>

ng-repeat Directive in AngularJS

ng-repeat directive is used on an array of objects to repeat an HTML element. We can use $index, $first, $last, $middle, $even, $odd with ngRepeat. Let try to understand it using examples.

Example 1:

  1. <ul>  
  2. <li data-ng-repeat="x in friends">  
  3.    {{ x }}  
  4. </li>  
  5. </ul>