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,
- Extension method - > introduced in .net 3.5
- Dynamic runtime - > introduced in 4.0
Create a simple class and inherit it from DynamicObject class (present in System.Dynamicnamesplace).
Create a Global level object which will hold TempData.
Create constructor for initializing GlobalTempData
Crete TempDataExtenion class as follows.
We are done with it. Let’s test our code.
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.