[Withvinay.com Powered By :- Vinay Sharma] DotNet Basics Page 3

0 views
Skip to first unread message

Vinay Sharma

unread,
Nov 28, 2011, 3:13:42 AM11/28/11
to with...@googlegroups.com

What are Value types and Reference types?
Value types directly contain their data which are either allocated on the stack or allocated in-line in a structure.

Reference types store a reference to the value's memory address, and are allocated on the heap. Reference types can be self-describing types,pointer types, or interface types.

Variables that are value types each have their own copy of the data, and therfore operations on one variable do not affect other variables. Variables that are reference types can refer to the same object;therfore, operations on one variable can affect the same object referred to by another variable. All types derive from the System.Object base type.
What is Boxing and Unboxing?
Boxing permits any value type to be implicitly converted to type object or to any interface type implemented by value type.Boxing is a process in which object instances are created and copy values into that instance.

Unboxing is vice versa of boxing operation where the value is copied from the instance into appropriate storage location.

sample code is given below

Dim x As Integer
Dim y As Integer
x = 10
' Boxing Process
y = x
'Unboxing Process
x = y 
What is the difference between VB.NET and c#?
Well this is the most debatable issue in .NET community and people treat there languages like religion. Its a subjective matter which language is best. Some like VB.NET's natural style and some like professional and terse C# syntaxes. Both use the same framework and speed is also very much equivalents. But still let's list down some major differences between them:

Advantages of VB.NET
Has support for optional parameters which makes COM interoperability much easy.
With Option Strict off late binding is supported.
Has the WITH construct which is not in C#
The VB.NET part of Visual studio .NET compiles your code in the background. While this is considered an advantage for small projects, people creating very large projects have found that the IDE slows down considerably as the project gets larger.

Advantages of C#
XML documentation is generated from source code but this is now been incorporated in Whidbey.
Use of this statement makes unmanaged resource disposal simple.
Access to Unsafe Code. This allows pointer arithmetic etc, and can improve performance in some situations. However, it is not to be used lightly, as a lot of the normal safety of C# is lost.
What is the diference between System exceptions and Application exceptions?
All exception derives from Exception Base class. Exceptions can be generated programmatically or can be generated by system. Application Exception serves as the base class for all application-specific exception classes. It derives from Exception but does not provide any extended functionality. You should derive your custom application exceptions from Application Exception.
Application exception is used when we want to define user defined exception, while system exception is all which is defined by .NET.
What is Code Access Security?
CAS is part of .NET security model that determines whether or not a piece of code is allowed to run and what resources it can use while running. Example CAS will allow an application to read but not to write and delete a file or a resource from a folder.
How to prevent my .NET DLL to be decompiled?
By design .NET embeds rich Meta data inside the executable code using MSIL. Any one can easily decompile your DLL back using tools like ILDASM (owned by Microsoft) or Reflector for .NET which is a third party. Secondly there are many third party tools which make this decompiling process a click away. So any one can easily look into your assemblies and reverse engineer them back into actual source code and unserstand some real good logic which can make it easy to crack your application.

The Process by which you can stop this reverse engineering is using "obfuscation". It is a technique which will foil the decompilers. There are many third parties (XenoCode,Demeanor for .NET) which provide .NET obfuscation solution. Microsoft includes one that is Dotfuscator Community Edition with Visual Studio.NET.
What is the difference between Convert.toString and .toString() method?
For Easy understanding see below code.

int i = 0;
MessageBox.Show(i.ToString());
MessageBox.Show(Convert.ToString(i));

The basic difference between them is "Convert" function handles NULLS while "i.ToString()" does not it will throw a NULL reference exception error. So as good coding practice using "convert" is always safe.
What is Native Image Generator(Ngen.exe)?
The Native Image Generator utility (Ngen.exe) allows you to run the JIT compiler on your assembly's MSIL and generate native machine code which is cached to disk. After the image is created .NET runtime will use the image to run the code rather than from the hard disk. Running Ngen.exe on an assembly potentially allows the assembly to load and execute faster, because it restores code and data stuctures fom the native image cache rather than generating them dynamically.
What is CodeDom?
"CodeDom" is an object model which represents actually a source code. It is designed to be language independent - once you create a "CodeDom" hierarchy for a program we can then generate the source code in any .NET compliant language.
What is Satellite Assembly?
Satellite assemblies, are assembly files (.dll) that contain localized resources for an application. Each satellite assembly file contains the resources for one culture. An application can have many satellite assemblies, depending on how many cultures the application supports.


--
Posted By Vinay Sharma to Withvinay.com Powered By :- Vinay Sharma at 11/28/2011 01:43:00 PM
Reply all
Reply to author
Forward
0 new messages