Support us .Net Basics C# SQL ASP.NET ADO.NET MVC Slides C# Programs Subscribe Buy DVD

Part 5 - C# Tutorial - Common Operators

Suggested Videos
Part 2 - Reading and writing to console
Part 3 - Built-in types
Part 4 - String type

In this video, we will discuss the common operators that are available in c# programming language.



Assignment Operator =
Arithmetic Operators like +,-,*,/,% 
Comparison Operators like ==, !=,>, >=, <, <= 
Conditional Operators like &&, ||
Ternary Operator ?:
Null Coalescing Operator ?? 



Program without ternary Operator
using System;
class Program
{
    static void Main()
    {
        int Number = 10;

        bool IsNumber10;

        if (Number == 10)
        {
            IsNumber10 = true;
        }
        else
        {
            IsNumber10 = false;
        }

        Console.WriteLine("i == 10 is {0}", IsNumber10);
    }
}

Same program with ternary Operator
using System;
class Program
{
    static void Main()
    {
        int Number = 10;

        bool IsNumber10 = Number == 10 ? true : false;
        
        Console.WriteLine("i == 10 is {0}", IsNumber10);
    }
}

1 comment:

  1. can you upload slides from video for download tnx

    ReplyDelete

If you like this website, please share with your friends on facebook and Google+ and recommend us on google using the g+1 button on the top right hand corner.