Day 1 of my MCTS Preparation

MCTS preparation
article. Here I am assuming that the reader has some acquaintance with programming and object oriented concepts.As I would be basically putting major differences in C# with respect to traditional programming like in C++, I would be glad to take up queries on any of these concepts.

best online Microsoft MCTS Training, Microsoft MCITP Certification login in to Certkingdom.com

Hope you will find it worthwhile. Good luck¦

1. Overview of MS .Net Platform
The MS .Net platform provides all of the tools and technologies that you need to build distributed web applications. It has:-

1. The .Net Framework
It provides necessary compile time and run time foundation to build and run .Net based application. It has:-

1. Common Language Runtime. The CLR,
o simplifies application development,
o provides a robust and secure execution environment,
o support multiple languages and
o Simplifies application deployment and management.
o It is also referred as a managed environment ,
o in which common services such as garbage collection and
o Securities are automatically provided.

2. Class Library
It exposes features of the runtime and provides application (Component, Message queuing, IIS etc.) and other services that can be extended further.

3. ADO .Net
Ahead of MS ActiveX DO, ADO.Net provides improved support for the disconnected programming model.

It also provides rich XML support.

4. User Interfaces Three types:-
o Web Form, works through ASP.Net
o Windows Form, works through Win32 client computer
o Console application

2. .Net My Services
It is a set of user centric XML web services. XML web services are programmable web components that can be shared among applications on the internet or intranet.

3. The .Net Enterprise Servers

It provides scalability, reliability, management and integration within and across organizations

4. Visual Studio .Net.Net Framework Advantages
1. Based on web standards and practices of existing internet technologies (HTML, XML, SOAP etc.)
2. Designed using unified application models for any .Net compatible language or programming model.
3. Easy to use, because of hierarchical namespaces and classes.
4. Extensible classes

2. C# Class “ is a user defined data type that contains a set of data and methods to manipulate that data.

A class cannot span multiple files. In C# application, there can be onle one entry point, but it is possible to have multiple classes each with Main, but only one of them will be executed on your specification.

Compilation command:-
csc myprogram.cs /
eg.
csc myprogram.cs /my_class_having_main_method__to_be_execute
csc myprogram.cs /?
csc myprogram.cs /help
csc myprogram.cs /debug

Execution process I II
C# source code
C# source code
MSIL

Machine code
(by JIT compiler @ runtime)
Machine code
(by Native Image Generator (Ngen.exe) utility)

Advantage :-
– loads faster because it restores code and data structures from native image cache rather than generating dynamically

Advantage :-
– loads faster because it restores code and data structures from native image cache rather than generating dynamically

3. Variables Types
Common Type System of CLR is the model that defines rules for declaring, using and managing types. 2 types of variables in C#:-

Value Type
Reference Type

1, Directly contain data Stores reference to data (i.e. objects)
2,  Each has its own copy of data

2 refs can refer to same objects
3 Operation on one can not affect other Operation on one can affect other

Value types All value types directly contain data, and they cannot be null. 2 types of VT:-
1. Built in type E.g. int, float

2. User defined E.g. enum. struct

* Besides assigning a value to a variable as assignment expression itself has a value, which is the value of the variable after the assignment has taken place.

Eg. Console.WriteLine(var = 2); prints 2
* You can use structs to create objects that behave like built in value types. Because structs are stored inline and are not heap allocated, there is less garbage collection pressure than classes.

Data Type Conversion

1. Implicit cannot fail may lose precision but not magnitude
2. Explicit Use a cast expression
*checked
{
Stmts expected to throw overflow exception
}

* C# does not support integer to Boolean conversion,

Eg.
If (x) //must be x!=0 in C#
If(x = 0) //must be x==0 in C#

Switch in C#
Enum MonthName{Jan, Feb,¦,Dec}
MonthName current;
Int monthDays;
¦
switch(current)
{
case MonthName.Feb:
monthDays = 28;
break;
case MonthName.April:
case MonthName.June:
case MonthName.September;
case MonthName.November:
monthDays = 30;
break;
default:
monthDays = 31;
break;
}

Q I want to ask:- One or more case labels cannot silently fall through or continue to the next case labels, why???

4. Exception handling
try
{
Stmnts causing exception
}
catch(OverflowException caught) {¦}
catch(DivideByZeroException caught) {¦}
catch(OutOfMemoryException caught) {¦}
catch(System.Exception) {¦} or catch{¦} /General catch block, has to be last of all catch blocks
Raising exceptions using œthrow
if (cond¦)
{
throw new InvalidTimException(œError message text!!);
}
The message can be displayed or logged

* You can œthrow only an object if the type of the object is directly or indirectly derived from System.Exception.
If you wan to retain the info of the exception thrown while raising another exception further then:-
catch(IOException caught)
{
throw new FileNotFoundException(filename,caught);
}

* A throw with no expression can be used, but only in a catch block.
catch(OutOfMemoryException caught)
{
throw caught; //equvivalent to rethrow of C++
}
catch(OutOfMemoryException caught) {throw; //same as above}

Finally block
1. Avoid duplication of statements
2. Release resources after the exception has been thrown

In finally block, don™t use:-
break;
continue;
goto;
return;

if it takes the control goes out of the finally block.
* C# program doesn™t check arithmetic for overflow, thus

int I = int.MaxValue; Console.WriteLine(++i);

will display -2147483648 , the largest negative int value.

So you can globally turn on/off the arithmetic overflow checking by:-
C: csc /checked+ mycsharpfile.cs ” on
C: csc /checked- mycsharpfile.cs ” off

For statement specific
checked
{
Statement list
}
unchecked
{
Statement list
}

5. Methods and Parameters
Method “ It is a named block of code that performs an action or computes a value. Dividing the application into functional units also allows reuse functional components.

Each method call needs memory to store return addresses and other information.

Mechanisms for passing parameters

3 ways to pass parameters to and from methods:-
1. By Value (to pass in)
2. Reference (to pass in/out)
3. Output (to pass out)

1. By Value (to pass in)
a. It is the default way
b. A new storage is assigned and value is copied
c. Variables can be changed inside method
d. Has no effect on the outside variable
e. Has to be of the same type or compatible type

2. Reference (to pass in/out)
a. Is the reference to the same memory location where the original variable is stored
b. Use œref in method declaration and call
c. Match types and variable values
d. Changes in method affect the caller
e. Have to assign value before calling the method
3. Output (to pass out)

Click to rate this post!
[Total: 0 Average: 0]

Author: admin

Hi I educated in the U.K. with working experienced for 18 years in multinational companies, As an IT Manager and IT Instructor, I am attached with certkingdom.com here they provide IT exams study material, the study materials included exams Q&A with Explanation, Study Guides, Training Labs, Exams Simulations, Training Videos, etc. for certification like MCSE 2003 Training, MCITP Training, http://www.certkingdom.com, CCNA exams preparation, CompTIA A+ Training, and more Certkingdom.com provide you the best training 100% guarantee. “Best Material Great Results”

Leave a Reply

Your email address will not be published. Required fields are marked *