?

Log in

Previous Entry | Next Entry

Download MVC interview question book PDF by clicking here. If you  want to learn MVC step by step start from this youtube video by clicking ->here.

Someone during interview to test you understanding skill may ask such kind question.
Answer for this question is, we cannot create exactly but get something like that with the help of two C# feature,

  1. Extension method  - > introduced in .net 3.5

  2. Dynamic runtime - > introduced in 4.0

Step 1
Create a simple class and inherit it from DynamicObject class (present in System.Dynamicnamesplace).

1.1

Step 2
Create a Global level object which will hold TempData.

2

Step 3
Create constructor for initializing GlobalTempData

3

Step 4
Override GetDynamicMemberNames,TryGetMember,TrySetMember of DynamicObject class as follow,

4

Step 5
Crete TempDataExtenion class as follows.

5

What’s next?

We are done with it. Let’s test our code.
6
7

Hope you enjoyed reading this and learned something.  Your comments and votes are always welcome.

If you are looking for some hard core live training on MVC,WCF,Design Patterns, BI,WPF,TFS,HTML5 visit www.sukesh-Marla.com or contact SukeshMarla@Gmail.com.
Copy right www.questpond.com

Buy 600+ Real Time Interview Videos

Call +91-22-66752917 or mail us on questpond@questpond.com for more details on C#, .NET, ASP.NET, SQL Server interview question videos.

SQL Server interview question videos

Latest Month

March 2017
S M T W T F S
   1234
567891011
12131415161718
19202122232425
262728293031 

Tags

Powered by LiveJournal.com