Skip to main content

Posts

Showing posts from July, 2017

C# - Loops

There may be a situation, when you need to execute a block of code several number of times. In general, the statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on. Programming languages provide various control structures that allow for more complicated execution paths. More Info:  C Sharp (programming language) A loop statement allows us to execute a statement or a group of statements multiple times and following is the general from of a loop statement in most of the programming languages: C# provides following types of loop to handle looping requirements. Click the following links to check their detail. Loop Type Description while loop It repeats a statement or a group of statements while a given condition is true. It tests the condition before executing the loop body. for loop It executes a sequence of statements multiple times and abbreviates the code that manages the loop variable. do...while

C# - Decision Making

Decision making structures requires the programmer to specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false. Following is the general form of a typical decision making structure found in most of the programming languages:  More Info:  C Sharp (programming language) C# provides following types of decision making statements. Click the following links to check their detail. Statement Description if statement An  if statement  consists of a boolean expression followed by one or more statements. if...else statement An  if statement  can be followed by an optional  else statement , which executes when the boolean expression is false. nested if statements You can use one  if  or  else if  statement inside another  if  or  else if  statement(s). switch statement A  swit

C# - Operators

An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. C# has rich set of built-in operators and provides the following type of operators: Arithmetic Operators Relational Operators Logical Operators Bitwise Operators Assignment Operators Misc Operators This tutorial explains the arithmetic, relational, logical, bitwise, assignment, and other operators one by one.  More Info:  C Sharp (programming language) Arithmetic Operators Following table shows all the arithmetic operators supported by C#. Assume variable  A  holds 10 and variable  B  holds 20 then: Show Examples Operator Description Example + Adds two operands A + B = 30 - Subtracts second operand from the first A - B = -10 * Multiplies both operands A * B = 200 / Divides numerator by de-numerator B / A = 2 % Modulus Operator and remainder of after an integer division B % A = 0 ++ Increment operator increases integer value by one A++ = 11 -- Decrement op

C# - Constants and Literals

The constants refer to fixed values that the program may not alter during its execution. These fixed values are also called literals. Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal. There are also enumeration constants as well. The constants are treated just like regular variables except that their values cannot be modified after their definition.  More Info:  C Sharp (programming language) Integer Literals An integer literal can be a decimal, or hexadecimal constant. A prefix specifies the base or radix: 0x or 0X for hexadecimal, and there is no prefix id for decimal. An integer literal can also have a suffix that is a combination of U and L, for unsigned and long, respectively. The suffix can be uppercase or lowercase and can be in any order. Here are some examples of integer literals: 212 /* Legal */ 215u /* Legal */ 0xFeeL /* Legal */ Following are other