Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

This is my Blog
Browse by Tags · View All
C#6.0 1
C#5.0 1
C#4.5 1
C#4.0 1
C#3.0 1
C#2.0 1
C# 1.0 1

Archive · View All
December 2014 1

Handle null in a called function whose parameter is nullable integer?

Dec 19 2014 12:00AM by Niladri Biswas   

Answer1: Check for null using EQUALITY Operator

a = a != null ? a : 0;
b = b != null ? b : 0;
return ( a+b );


Answer2: Check for null using HasValue Operator

if (!a.HasValue) a = 0;
if (!b.HasValue) b = 0;
return (a + b);

Answer3: Check for null using Null coalescing Operator

return (a ?? 0) + (b ?? 0);

Answer4: Use GetValueOrDefault method of Nullable<T> which will substitute the default value of T, which is zero for int, if it is null.

return a.GetValueOrDefault() + b.GetValueOrDefault();

Answer5:  Null-Conditional Operator ( C# 6.0 )

return (a?. + b?.);

Answer 6:  And of-course

return (a + b);

Tags: C# 1.0,C#2.0,C#3.0,C#4.0,C#4.5,C#5.0,C#6.0

  • Previous: 
  • Next: 

Niladri Biswas
7 · 21% · 6720
0
Liked
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]