MVC Developer Question:
Download Job Interview Questions and Answers PDF
Tell us what are the Difference between ViewBag&ViewData?
Answer:
☛ ViewData is a dictionary of objects that is derived from ViewDataDictionary class and accessible using strings as keys.
☛ ViewBag is a dynamic property that takes advantage of the new dynamic features in C# 4.0.
☛ ViewData requires typecasting for complex data type and check for null values to avoid error.
☛ ViewBag doesn't require typecasting for complex data type.
Calling of ViewBag is:
ViewBag.Name = "Hasan";
Calling of ViewData is :
ViewData["Name"] = " Hasan ";
☛ ViewBag is a dynamic property that takes advantage of the new dynamic features in C# 4.0.
☛ ViewData requires typecasting for complex data type and check for null values to avoid error.
☛ ViewBag doesn't require typecasting for complex data type.
Calling of ViewBag is:
ViewBag.Name = "Hasan";
Calling of ViewData is :
ViewData["Name"] = " Hasan ";
Download MVC Developer Interview Questions And Answers
PDF
Previous Question | Next Question |
Suppose if we have multiple filters, what’s the sequence for execution? | Tell us what is display mode in MVC? |