Skip to main content

Posts

Showing posts from June, 2016

C# - Decision Making

  <<PreviousPage     NextPage>> Decision Making If Else Statement If Else statement is used for decision making in c# . In the below example we will see how we can use if else statement in C# to great effect.   Nested If Else Statement We can improve upon the above example by adding nest if else statement. Nested if else statement helps to add extra if else block with in an if or else block. Switch Statement In place where we need multiple if else statements to satisfy a criteria we can add switch statement instead of if else statement.  We can create an application which would answer our question and let us know about the Date and Time. This will be a small AI sort of idea which would recognize your command and perform accordingly.  Code -    Console.WriteLine("................Welcome to Mini AI................");            str...

C# - Operators

  <<PreviousPage     NextPage>> Operators In this session we are going to discuss about various types of operators in use in C# Arithmetic Operator Relational Operator Logical Operator Bitwise Operator Assignment Operator Misc Operator Conditional Operator Arithmetic Operator + - * / % ++ --  Use  Arithmetic Operator  Relational Operator == != > < >= <= Use  Relational Operator Logical Operator   && || ! Use  Logical Operator Bitwise Operator ~ ^ | & << >> Use  Bitwise Operator In case of bitwise operator we need to discuss about what operations these symbols perform. suppose we have 2 variables A and B.  if A = 9 and B = 12 then A in binary is 1001, B in binary is 1100 Then A | B = A OR B = 00001001 OR 00001100 =0 0 0 0 1 1 0 1 = 13 Then A & B = A AND B = 00001001 AND 00001100 = 0 0 0 ...

C# - Data Type Conversion

  <<PreviousPage      NextPage>> Data Type Conversion  In our previous tutorial we have seen various types of data and how to use them. In this session we are going to look into how to convert these data type from one to another.  Implicit Conversions In Implicit conversion can be made when the value to be stored can fit into the variable without being truncated or rounded off. We can take example of int and long, float and double. we can declare a variable int and assign it to a long type which is an implicit conversion as the scope of long is bigger than that of int so there is no worry of loosing data.  Explicit Conversions However, if a conversion cannot be made without a risk of losing information, the compiler requires that you perform an explicit conversion, which is called a cast. A cast is a way of explicitly informing the compiler that you intend to make the conversion and that you are aware ...

C# - DataTypes

                                                                                                      <<PreviousPage      NextPage>> Data Types Value Type  Variable contains value directly  Derived implicitly from the System.ValueType Cannot derive a new type from a value type. example of value type - int, float, enum. Builtin data types apart from the above mentioned built in data types we need to discuss two special type of data types - Struct and Enum Struct -  A struct type is a value type that is typically used to encapsulate small groups of related variables In the below example we are using a struct variable Book which has one decimal value price an...