September 26, 2008

MCP Defined



“The certification process itself consists of three levels –



MCP



-> MCAD



-> MCSD for the
.NET Framework 1.1 track.



You need to take 6 papers in all 5 compulsory and the last one you have a
choice.



You are an MCP when you clear any one paper of your liking!! You need to make up
your mind whether you want to follow the VB.NET track or the C#.NET track before
starting to prepare. You cannot take one paper from one track and take a
parallel paper from the other track and claim credits.



The papers are as follows:



1) C#.NET / VB.NET



2) ASP.NET (C# or VB.NET track)



3) XML and Web Services (C# or VB.NET track)



4) SQL Server 2000 or higher



5) Project Management



6) You have to choose one of several papers – (Commerce Server/ Exchange Server
etc …)



You become an MCP if you clear any one of the first 5 papers. You are an MCAD
when you clear papers 1 through 4. When you have all 6 you are an MCSD.NET.
However, with 2005, Microsoft has already started upgrade exams. In another
year, they would have a separate track for VS 2005!!
MCSD.NET will
still continue to be recognized at least for the next three years!!



My suggestion – go for paper 1 and make up your mind which track you want to
follow!”



So I chose to sit for MCP 70-315 (ASP.NET with C#).



click here for more info mcitp training

click here for more info mcst training

Boxing/Unboxing in .NET



This post has been long overdue; I should have posted it two months back.
Anyway, a couple of my friends attended training in .NET concepts sponsored by
my company. They came back from the training and discussed with me the stuff
they had learnt. One of the fellows mentioned that they had been taught that
int.ToString() converts an integer (a value type) to a string (a reference type)
and hence, boxes the int. On the other hand, int.Parse() converts a string to an
integer and hence, unboxes the string. When I heard that, I knew deep within me
that what they had been taught was incorrect. But, I did not know why. So, I set
out to find the answer. To find out what happens during a call to int.ToString(),
I decompiled mscorlib.dll (It is present is the .NET Framework directory which
on my machine happens to be C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727) which
contains the implementation of Int32 using Lutz Roeder’s .NET Reflector.



The implementation of ToString() is as follows:



public override string ToString()

{

return Number.FormatInt32(

this,

null,

NumberFormatInfo.CurrentInfo);

}



The Number.FormatInt32() method is declared as follows:



[MethodImpl(MethodImplOptions.InternalCall)]

public static extern string FormatInt32(

int value,

string format,

NumberFormatInfo info);



According to MSDN, the extern modifier is used in C# to declare a method that is
implemented externally. So, the question is: where is FormatInt32() (see above
code fragment) implemented? The answer lies in the MethodImpl attribute which
decorates the method declaration. According to MSDN,
MethodImplOptions.InternalCall specifies that the method is implemented in the
CLR itself. So, I proceeded to download SSCLI a.k.a. Rotor (source code to a
working implementation of the CLR) from here.



I learnt from this site that the ecall.cpp file (which is located at \clr\src\vm\ecall.cpp
in the SSCLI) contains a table that maps managed internal call methods to
unmanaged C++ implementations. I searched for FormatInt32 and found the
following code:



FCFuncElement("FormatInt32", COMNumber::FormatInt32)



This tells that the implementation of FormatInt32 method is actually the
implementation of the native C++ COMNumber::FormatInt32 function. So, the next
question is where do I find the implementation of COMNumber::FormatInt32
function? I noticed that there was a file named comnumber.cpp in the \clr\src\vm
directory. I opened the file and started to examine the COMNumber::FormatInt32
function. I discovered that COMNumber::FormatInt32 calls COMNumber::Int32ToDecChars
function. This function is defined as follows:



wchar_t* COMNumber::Int32ToDecChars(

wchar_t* p,

unsigned int value,

int digits)

{

LEAF_CONTRACT

_ASSERTE(p != NULL);



while (--digits >= 0 || value != 0) {

*–p = value % 10 + ‘0′;

value /= 10;

}

return p;

}



As you can see here, COMNumber::Int32ToDecChars takes each digit of the integer
starting from the rightmost digit and proceeding to the leftmost, converts it to
the equivalent character and stores it in a string and returns the string. There
is actually more action that goes on inside COMNumber::FormatInt32 but, I won’t
be discussing that here. The core function is performed by COMNumber::Int32ToDecChars.
So, I would wrap up the discussion of int.ToString() function by saying that it
converts individual digits of an integer to their equivalent characters, stores
them in a string and returns the string.



Next, I tried to figure out what goes on inside int.Parse(). I used .NET
reflector and found out that it is pretty similar to what int.ToString() does.
The string is read character-by-character, converted to its equivalent digit and
added to a number after the digits converted previously have been shifted by one
position.



Most C# textbooks provide an example as shown below for boxing/unboxing:



int i = 1729;

object o = i; // Boxing

int j = (int)o; // Unboxing



int.ToString() and int.Parse() cannot be used in the above manner and so, these
functions are not even remotely related to boxing/unboxing.



My final task was to find out what actually happens during boxing/unboxing. The
documentation that is available made my task easy. I referred the following:



1. C# Language Specification

2. Shared Source CLI Essentials - By David Stutz, Ted Neward and Geoff Schilling



See the excerpts from Shared Source CLI Essentials:



By default, when an instance of a value type is passed from one location to
another as a method parameter, it is copied in its entirety. At times, however,
developers will want or need to take the value type and use it in a manner
consistent with reference types. In these situations, the value type can be
“boxed”: a reference type instance will be created whose data is the value type,
and a reference to that instance is passed instead. Naturally, the reverse is
also possible, to take the boxed value type and dereference it back into a value
type - this is called “unboxing”.



The box instruction is a typesafe operation that converts a value type instance
to an instance of a reference type that inherits from System.Object. It does so
by making a copy of the instance and embedding it in a newly allocated object.
For every value type defined, the type system defines a corresponding reference
type called the boxed type. The representation of a boxed value is a location
where a value of the value type may be stored; in essence, a single-field
reference type whose field is that of the value type. Note that this boxed type
is never visible to anyone outside the CLI’s implementation-the boxed type is
silently generated by the CLI itself, and is not accessible for programmer use.
(It is purely an implementation detail that would have no real utility were it
exposed.)



This is made clearer by the C# language specification. Please refer to section
4.3 of the specification.



click here for more info mcitp training


click here for more info mcst training

The Day 1 of my MCTS Preparation

This is the Day 1 of my
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.



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 here for more info mcitp training

click here for more info mcst training

Build up your future carrier through Logic!!!

Logic's Training division starts with the very strong aspiration of a simple logic to provide Competitive and World-class quality-maintained Education & Training in God's own Country. It is Logic that introduced the concept of Online Certification Courses first in United States; it laid our Firm-Foundation. Presently Logic operates with our four Direct Centres at Key locations in United States.

According to latest trends taking an International Certification is the blueprint to the successful IT profession, Logic played a big role in this revolution and we are pride to be famous as The Legend in Online Certifications. In this IT booming stage Logic comes in the first row among the best training institutes in United States, imparting advanced training in products from Microsoft, Cisco Systems, Sun Microsystems, Checkpoint, IBM, Lotus Corporation, Oracle Corporation etc. Our service infrastructure is the best in the industry backed up with faculties certified in MCP, MCSA, MCSE, MCAD, MCSD,MCTS,MCPD, CCNA, CCNP,CCVP,CCIE, OCP, SCSA etc., who believes in 100% practical, oriented training, in higher end LAN and WAN connectivity and our syllabus is designed according to the Industry Requirements.

In the past Successful years we have molded thousands of, Hardware Software and Network Engineering professionals who have achieved envious positions in their respective fields to the fullest extent.


click here for more info mcitp training


click here for more info mcst training


click here for more info ccie lab


click here for more info ccna exams


click here for more info mcse training


click here for more info mcse 2003 training


click here for more info mcdst training


click here for more info mcsa training


click here for more info ccnp training


click here for more info mcap training


click here for more info Microsoft Office Specialist

Bookmark and Share