Visual C # ▼

Visual Studio dump files notes start without debugging Visual Studio unsafe code notes
Imports System.IO
IO stands for input & output
   
Exception handling mechanism consists Four keywords▼
1 try
2 catch
3 throw The endpoint of a throw statement is never reachable
4 finally An important characteristic of the finally clause is that all of the statements in a finally block are always executed
acronym meaning ▼
XML Extensible Markup Language.
SOAP Simple Object Access Protocol.
ASP.NET Active Server Pages
 CLR Common Language Runtime: manages garbage collection 
DNA Windows Distributed interNet Architecture   
 1: Win32 client applications, simply to create , difficult to maintain
2: Browser-based interfaces difficult to create, easy to maintain
WBS Work breakdown structure
CTS Common Type System
DLL Dynamic Link Library
RAD Rapid Application Development
ASDI Active Directory Services Interface
CDO Collaborative Data Objects
ADO ActiveX Data Objects
ADT's Abstract Data Types
UML Unified Modeling Language
BCL Base Class Language
COM Component Object Model
RCW Runtime Callable Wrapper
IDE Interactive Development Environment
C# ▼
To declare a variable.......write the name of the data type, followed by the name of the variable.

int outcome;
Unicode is a superset of the ASCII character set and is able to handle 65,536 character combinations rather than just 256
To change the value of a variable.......write the name of the variable on the left followed by the assignment operator, followed by the expression calculating the new value.

outcome = 42;

To add an amount to a variable............use the compound addition operator

variable += amount;
To convert a string to an int.........call the System.Int32.Parse method.

System.Int32.Parse("42");
To subtract an amount from a variable............use a while statement.

variable -= amount;
To override precedence..... use parentheses in the expression to force the order of evaluation.

(3 + 4) * 5
To run one or more statements while a condition is true.......use a while statement.

int i = o;
while(i < 10)
{
Console.Writeline(i);
i++;
}

Alternatively, use a for statement.

for(int i = 0; i < 10; i++)
{
Console.Write(i);
}
To initialize several variables to the same value....... use an assignment statement that initializes all the variables.

myInt4 = myInt3 = myInt2 = myInt = 10;
To repeatedly execute statements one or more times............ use a do statement.

int i = 0;
do
{
Console.Writeline(i);
i++;
}
while(i < 10);
To increment or decrement a variable......... use the ++ or -- operator end with semi-colon.

count++;
To throw an exception........... use a throw-statement.

throw new FormatException(source);
To declare a method........write the method inside a class.

int addValues(int lehtHandSide, int rightHandSide)
{
......
}
To ensure that integer arithmetic is always checked for overflow...........use the checked keyword.

int number = Int32.MaxValue;
checked
{
number++;
}
To return a value from inside a method..........write a return statement inside the method.

return;
To catch a specific exception...... write a catch handler that catches the specific exception class.

try
{
....
}
catch(FormatException fEx)
{
....
}
To call a method...........write the name of the method, together with any arguments between parentheses.

addValues(39, 3);
To catch all exceptions in a single catch handler..... write a catch that catch's Exception.

try
{
....
}
catch(Exception exc)
{
.....
}
To use the Generate Method Stub Wizard.
Right-click a call to the method, and then click Generate Method Stub on the shortcut menu.
To ensure that some code will always be run, even if an exception is thrown..... write the code inside a finally block.

try
{
.....
}
finally
{
// always run
}
To display the Debug toolbar.
On the view menu, point to Toolbars, and then click Debug.
To declare a class.........write the keyword class, followed by the name of the class, followed bay an opening and closing brace. The method and fields of the class are declared between the opening and closing braces.

class Point
{
....
}
To step into a method.............on the debug toolbar, click step into.
or
on the debug menu, click step into.
To declare a constructor......... write a method whose name is the same as the name of the class and that has no return type(not even void)

class Point
{
public Point(int x, int y)
{
....
}
}
To step out of a method........... on the debug toolbar, click step out.
or
on the debug menu, click step out.
To call an constructor.... use the new keyword, and specify the constructor with an appropriate set of parameters.



Point origin = new Point(0, 0);
To determine whether two values are equivalent.......... use the == or the != operator.

answer  == 42
To declare a static method.... write the keyword static before the declaration of the method.

class Point
{
public static int ObjectCount()
{
...
}
}
To compare the value of two expressions...........use  the <, <=, > >=, operator.

age >= 21
To call a static method.... write the name of the class, followed by a period, followed by the name of the method.

int pointsCreatedSoFar = Point.ObjectCount();
To declare a boolean value...... use the bool keyword as the type of the variable.

bool inRange;
To declare a const field..... write the keyword const before the declaration of the field, and omit the static keyword.



class Math
{
...
public const double PI = ...;
}
To create a boolean expression that is true it either of two other conditions is true............... use the &&  conditional AND operator.

inRange = (1 <= number) && (number <= hi);
To access a static field.... write the name of the class, followed by a period, followed by the name of the static field.

double area = Math.PI * radius * radius;
To run a statement if a condition is true...............use an if statement

If()inRange
process();

To copy a value type variable.....simply make the copy. Because the variable is a value type, you will have two copies of the same value.

int i = 42;
int copyi = i;
To run more than one statement if a condition is true...............use an if statement and a block.

If(seconds == 59)
{
seconds = 0;
minutes++;
}
To copy a reference type variable......simply make the copy. Because the variable is a reference type, you will have two references of the same object.

Circle c = new Circle(42);
Circle refc = c;
To associate different statements with different values of a controlling expression.........use a switch statement.

switch(current)
{
            case 0:
...
            break;
             case 1:
...
            break;
             default :
...
            break;
 }
To declare a variable that can hold a value type or the null value.....declare the variable using the ? modifier with the tupe.


int? i = null;
To declare an array variable..........write the name of the element type, followed by square brackets followed by the name of the variable.

bool[] flag;
To pass an argument to a ref parameter.... prefix the argument with the ref keyword. This makes the parameter an alias for the actual argument rather than a copy of the argument.


static void Main()
{
int arg = 42;
DoWork(ref arg);
Console.Writeline(arg);
}
To create an instance of an array,,, write the keyword new, followed by the name of the element type, followed by the size of the array enclosed in square brackets.

bool[] flag = new bool[10];
To pass an argument to an out parameter.... prefix the argument with the out keyword. This makes the parameter an alias for the actual argument rather than a copy of the argument.

static void Main()
{
int arg = 42;
DoWork(out  arg);
Console.Writeline(arg);
}

To initialize the element of an array(or of a collection that supports the Add method) to specific values........... For an array, write the specific values in a comma-separated list enclosed in braces.


bool[] flag ={ true, false, true, false};



For a collection, use the new operator and the collection type with the specific values in a comma-separated list enclosed in braces.

ArrayList numbers = new ArrayList(){10, 9, 8, 7, 6, 5};




To box a value..... initialize or assign a variable of type object to the value.


Object o = 42;


To unbox a value.....cast the object reference that refers to the boxed value to the type of the value variable.

int i =  (int)o;
To find the number of elements in an array.... use the length property.


int[] flags = ....;
...
int no0fElements = flags.Length;
To cast an object safely..... use the is operator to test whether the cast is valid.


WrappedInt wi = new WrappedInt();
...
object o = wi;
if(o is WrappedInt)
{
WrappedInt temp = (WrappedInt)o;
..
}


Alternatively.........use the as operator to perform the cast and test whether the result is null.

WrappedInt wi = new WrappedInt();
object o = wi;
WrappedInt temp = o as  WrappedInt;
if(temp != null)
...


To find the number of elements in a collection.... use the Count property.



ArrayList flags = new ArrayList();
...
int no0fElements = flag.Count;
To declare an enumeration.....write the keyword enum, followed by the name of the type, followed by a pair of braces containing a comma-separated list of the enumeration literal names.

enum Season(spring, Summer, Fall, Winter)
To access a single array element.... write the name of the array followed by the integer index of the element enclosed in square brackets. Remember array indexing starts at 0, not 1.

bool initiallElement = flags[0];


To declare an enumeration variable.... write the name of the enumeration on the left followed by the name of the variable.

Season currentSeason;
To Iterate through the elements of an array or a collection.... use a for statement or a foreach statement.


bool[] flags ={true, false, true, false};
for(int i = o; i < flags.Length; i++)
{
Console.Writeline(flags[i]);
}
foreach(bool flag in flags)
{
Console.Writeline(flag);
}
To assign an enumeration variable to a value..... write the name of the enumeration literal in combination with the name of the enumeration to which it belongs.

current = Spring; // error
currentSeason =  Season.Spring; // correct
To declare an array variable... write the name of the element followed by square brackets, followed by the name of the variable.


bool[] flags;
To declare a structure type.... write the keyword struct, followed by the name of the structure type, followed by the body of the structure(the constructors, methods, and fields)


struct Time
{
public Time(int hh, int mm, int ss)
{...}
private int hours, minutes, seconds;
}
To create an instance of an array.... write the keyword new, followed by the name of the element type, followed by the size of the array enclosed in square brackets.


bool[] flags = new bool[10];
To declare a structure variable.... write the name of the structure type, followed by the name of the variable.

Time now;


To initialize a structure variable to a value.... initialize the variable to a structure value created by calling the structure constructor.

Time lunch = new Time(12, 30, 0);
To initialize the elements of an array(that supports the Add method) to specific values......... for an array, write the specific values in a comma-separated list enclosed in braces.

bool[] flags = {true, false, true. flase};


for a collection, use the new operator and the collection type with the specific values in a comma-separated list enclosed in braces.

ArrayList numbers = new ArrayList(){10. 9, 8, 7, 6, 5};
 
To find the number elements in a array.... use the Length property.

int[] flags = ....;
...
int noOfElements = flags.Length;
 
To find the number of elements in a collection.... use the Count property.


ArrayList flags = new ArrayList();
...
int noOfElements = flags.Count.
 
To access a single array element....  write the name of the array variable, followed by the integer index of the element enclosed in square brackets. Remember Array indexing starts at 0, not 1.


bool initiallElement = flags[0];
 
To Iterate through the elements of array or a collection... use a for statement or a foreach statement.



bool[] flags ={true, false, true, false};
for(int i = 0; i < flags.Length; i++)
{
Console.Writeline(flags[i]);
}
foreach(bool flag in flags)
{
Console.Writeline(flag);
}
 
To write a method that accepts any number of arguments in a given type..... write a method whose parameter is a params array of the given type. Example a method that accepts any number of bool arguments would be declared like this below.

someType Method(params bool[] flags)
{
...
}
 
To write a method that accepts any number of arguments of any type.... write a method whose parameter is a params array whose elements are of type object.

someType Method(params object[] paramList)
{
...
}
 
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
Visual Basic.NET Operators▼ Visual C# Operators▼ Description▼
> > greater than
>= >= greater than or equal to
< < less than
<= <= less than or equal to
<> != not equal to
= == equals
= = assigns a value to a variable
OrElse || or
AndAlso && and
& + concatenate strings
New new create an object or array
* * multiply
/ / divide
+ + add
- - subtract