.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> C# >> Post New Question Subscribe to Interview Questions

How the Dynamic works .net 4.0?

Posted By :senthilstayss     Posted Date :March 13, 2013    Points :40   Category :C# 
We are going to see how the Dynamics work in .Net now. For example consider the following statement.

dynamic d=GetSomeData(15); When we execute this statement,Let's see what will happen behind the scenes.

When the above statement executes, the DLR will pass the expression trees to the target object.If the dynamic data type is pointing in memory to a COM object, then the expression tree will be sent to the COM interface named IDispatch. This interface is COM's way of incorporating its own set of dynamic services.

If the dynamic data is not pointing to a COM object, then the expression tree may be passed to the object implementing the IDynamicObject interface.This interface is used to map the expression tree to Ruby specifics in the dynamic languages like Iron Ruby.

If suppose the dynamic data is not pointing to COM object and does not implement IDynamicObject, then the object will be considered as .Net object. In this case the expression tree is sent to the C# run time binder for processing.

After the expression tree has been processed by the given binder, the dynamic data will be resolved to the real in-memory data type after which the correct method is called with any necessary parameters.

To know more about the expression tree basics , please read the following article.

http://www.codeproject.com/Articles/235860/Expression-Tree-Basics

Check this blog for more info about var and dynamic:-

senthilvijayalakshmi.blogspot.in/2013/03/difference-between-var-and-dynamic.html


You can also find related Interview Question to How the Dynamic works .net 4.0?  below: 

What is JIT (just in time)? how it works?

  
Before Microsoft intermediate language (MSIL) can be executed, it must be converted by a .NET Framework just-in-time (JIT) compiler to native code, which is CPU-specific code that runs on the same computer architecture as the JIT compiler.
Rather than using time and memory to convert all the MSIL in a portable executable (PE) file to native code, it converts the MSIL as it is needed during execution and stores the resulting native code so that it is accessible for subsequent calls.
The runtime supplies another mode of compilation called install-time code generation. The install-time code generation mode converts MSIL to native code just as the regular JIT compiler does, but it converts larger units of code at a time, storing the resulting native code for use when the assembly is subsequently loaded and executed.
As part of compiling MSIL to native code, code must pass a verification process unless an administrator has established a security policy that allows code to bypass verification. Verification examines MSIL and metadata to find out whether the code can be determined to be type safe, which means that it is known to access only the memory locations it is authorized to access. (More...)

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:

The garbage collector searches for managed objects that are referenced in managed code.

The garbage collector attempts to finalize objects that are not referenced.

The garbage collector frees objects that are not referenced and reclaims their memory. (More...)

What is the difference between "dynamic SQL" and "stored procedure" ?

  
Dynamic sql is the bunch of statements that dynamically constructed at run time and not stored in database.
Where as Stored procedures are stored in data base in complied form. (More...)

What is dynamic binding ? How is it different from static binding?

  
With dynamic binding, the decision on which object method to call is made at runtime.Dynamic binding is polymorphism. with static binding, the decision to on which method to call is made at compile time.c# uses static binding as the default method dispatching mechanism. (More...)

What is the difference between var and dynamic types in C# 4.0?

  
var gets processed in the compile time itself and shows any error during compile time itself.

dynamic gets processed in the runtime only and in case of errors it is hidden until runtime.

dynamic was introduced as part of the DLR (Dynamic Language Runtime) in .Net.

Example:
dynamic d = new MyClass();
d.InexistingMethod();

Eventhough the method "InexistingMethod" is not there - it will get compiled and thrown exception in runtime.

(More...)

What is dynamic variable in java and where do we use them?

  
The variables that are initialized at run time is called as dynamic variable (More...)

What is GC (Garbage Collection) and how it works

  
One of the good features of the CLR is Garbage Collection, which runs in the background collecting unused object references, freeing us from having to ensure we always destroy them. In reality the time difference between you releasing the object instance and it being garbage collected is likely to be very small, since the GC is always running.
[The process of transitively tracing through all pointers to actively used objects in order to locate all objects that can be referenced, and then arranging to reuse any heap memory that was not found during this trace. The common language runtime garbage collector also compacts the memory that is in use to reduce the working space needed for the heap.]

Heap:
A portion of memory reserved for a program to use for the temporary storage of data structures whose existence or size cannot be determined until the program is running.
(More...)

Statics and Dynamic Polymporphism

  
Method Overloading or Static Polymorphism

Method overloading means having two or more methods with the same name but with different signatures



Method Overriding or Dynamic Polymorphism

Method overriding means having two or more methods with the same name , same signature but with different implementation. (Base class and Child class implementation of a method with same name and signature) (More...)

What is static linking and dynamic linking library

  
Dynamic linking includes only the information needed at runtime to locate the code for a DLL function but in static linking , the linker gets all of the referenced function from a static library and places into your code. (More...)

What are dynamic objects?

  
Dynamic objects are changed during time of test execution. (More...)

How does Client object model works ?

  
Ans. When we use SharePoint client API's to perform a specific task, the SharePoint Foundation 2010 managed client object model bundles up these uses of the API into XML and sends it to the server that runs SharePoint Foundation. The server receives this request, and makes appropriate calls into the object model on the server, collects the responses, forms them into JavaScript Object Notation (JSON), and sends that JSON back to the SharePoint Foundation 2010 managed client object model. The client object model parses the JSON and presents the results to the application as .NET Framework objects (or ECMAScript objects for ECMAScript) (More...)

How does Ribbon works ?

  


Ans. A file called CMDUI.XML stays at the web front end which contains the Out-of-Box site wide Ribbon implementation i.e. all the Ribbon UI for the entire site. In addition to this you have a CustomAction for each ribbon component. These CustomActions have CommandUIExtentions block which has CommandUIDefinitions and CommandUIHandlers which make up the activity of the ribbon component. So, when the ribbon is loaded the CommandUIDefinition merges with Out-of-Box definition in the CMDUI.XML
(More...)

How does Client object model works ?

  
Ans. When we use SharePoint client API's to perform a specific task, the SharePoint Foundation 2010 managed client object model bundles up these uses of the API into XML and sends it to the server that runs SharePoint Foundation. The server receives this request, and makes appropriate calls into the object model on the server, collects the responses, forms them into JavaScript Object Notation (JSON), and sends that JSON back to the SharePoint Foundation 2010 managed client object model. The client object model parses the JSON and presents the results to the application as .NET Framework objects (or ECMAScript objects for ECMAScript).

(More...)

Q. How does Client object model works ?

  
Ans. When we use SharePoint client API's to perform a specific task, the SharePoint Foundation 2010 managed client object model bundles up these uses of the API into XML and sends it to the server that runs SharePoint Foundation. The server receives this request, and makes appropriate calls into the object model on the server, collects the responses, forms them into JavaScript Object Notation (JSON), and sends that JSON back to the SharePoint Foundation 2010 managed client object model. The client object model parses the JSON and presents the results to the application as .NET Framework objects (or ECMAScript objects for ECMAScript).
(More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

 
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend