Tuesday, March 10, 2009

Interview Question On Dot Net

16.What is Custom attribute? How to create? If I'm having custom attribute in an
assembly, how to say that name in the code?

A: The primary steps to properly design custom attribute classes are as follows:
Applying the AttributeUsageAttribute ([AttributeUsage(AttributeTargets.All, Inherited =
false, AllowMultiple = true)])
Declaring the attribute. (class public class MyAttribute : System.Attribute { // . . . })
Declaring constructors (public MyAttribute(bool myvalue) { this.myvalue = myvalue; })
Declaring properties public bool MyProperty{get {return this.myvalue;}set {this.myvalue
= value;}} The following example demonstrates the basic way of using reflection to get
access to custom attributes. class MainClass {public static void
Main(){System.Reflection.MemberInfo info = typeof(MyClass);object[] attributes =
info.GetCustomAttributes();for (int i = 0; i <>

17.What is the managed and unmanaged code in .net?

The .NET Framework provides a run-time environment called the Common Language
Runtime, which manages the execution of code and provides services that make the
development process easier. Compilers and tools expose the runtime's functionality and
enable you to write code that benefits from this managed execution environment. Code
that you develop with a language compiler that targets the runtime is called managed
code; it benefits from features such as cross-language integration, cross-language
exception handling, enhanced security, versioning and deployment support, a simplified
model for component interaction, and debugging and profiling services.

18.using directive VS using statement
You create an instance in a using statement to ensure that Dispose is called on the object
when the using statement is exited. A using statement can be exited either when the end
of the using statement is reached or if, for example, an exception is thrown and control
leaves the statement block before the end of the statement.The using directive has two
uses:
a.Create an alias for a namespace (a using alias).
b.Permit the use of types in a namespace, such that, you do not have to qualify the use of
a type in that namespace (a using directive).

19.Describe the Managed Execution Process?

The managed execution process includes the following steps:
a.Choosing a compiler. To obtain the benefits provided by the common language
runtime, you must use one or more language compilers that target the runtime.
b.Compiling your code to Microsoft intermediate language (MSIL). Compiling translates
your source code into MSIL and generates the required metadata.
c.Compiling MSIL to native code. At execution time, a just-in-time (JIT) compiler
translates the MSIL into native code. During this compilation, code must pass a
verification process that examines the MSIL and metadata to find out whether the code
can be determined to be type safe.
d.Executing your code. The common language runtime provides the infrastructure that
enables execution to take place as well as a variety of services that can be used during
execution.

20.How Garbage Collector (GC) Works?

The methods in this class influence when an object is garbage collected and when
resources allocated by an object are released. Properties in this class provide information
about the total amount of memory available in the system and the age category, or
generation, of memory allocated to an object. Periodically, the garbage collector performs
garbage collection to reclaim memory allocated to objects for which there are no valid
references. Garbage collection happens automatically when a request for memory cannot
be satisfied using available free memory. Alternatively, an application can force garbage
collection using the Collect method.Garbage collection consists of the following steps:
a.The garbage collector searches for managed objects that are referenced in managed
code.
b.The garbage collector attempts to finalize objects that are not referenced.
c.The garbage collector frees objects that are not referenced and reclaims their memory.

21.Why do we need to call CG.SupressFinalize?

Requests that the system not call the finalizer method for the specified object. [C#]public
static void SuppressFinalize( object obj); The method removes obj from the set of objects
that require finalization. The obj parameter is required to be the caller of this
method.Objects that implement the IDisposable interface can call this method from the
IDisposable.Dispose method to prevent the garbage collector from calling Object.Finalize
on an object that does not require it.

22.What is nmake tool?

The Nmake tool (Nmake.exe) is a 32-bit tool that you use to build projects based oncommands contained in a .mak file.usage

No comments:

Post a Comment