Search This Blog

Friday, December 6, 2013

Abs C# example

C#  > System > Math class > Abs

Abs returns the absolute value of a number.

Example:

int i = -32;
int j = Math.Abs(i); // 32




Math class C#

C#  > System > Math class

Math is a static class which contains constants and methods mathematical functions.




System namespace in C#

C# > System Namespace

System namespace in C# contains fundamental classes and base classes.





Guid, NewGuid C# example

C#  > System > Guid

Guid is globally unique identifier and stored on 128 bit integer.
The probability to be duplicated over networks and computers is very low.

Example
1. Use NewGuid method to get a new guid.
  Guid g = Guid.NewGuid();





Thursday, December 5, 2013

Call Stack Window Microsoft Visual Studio

Visual Studio > Call Stack Window

Using the Call Stack Window  you can view the function calls that are currently on the stack.
To open Call Stack Window click on
DEBUG > Windows > Call Stack








Foreach in C# example

C# > Statements > foreach, in

Foreach iterates through the collection . It can be exited by the goto, return, or throw.
Note: Cannot be used to add or remove items from the collection to avoid unpredictable side effects

Example


int[] intarray = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

foreach (int el in intarray)
{
MessageBox.Show(el.ToString()); 
}






C# Statements

C# > Statements

Statements are executed in sequence and are program instructions

Selection
Iteration
Jump
Namespace