---
title: "How to create dynamic property with the help of ViewBag in Asp.net MVC?"  
description: "How to create dynamic property with the help of ViewBag in Asp.net MVC?"  
author: "Chris Anderson"  
published: 2011-09-17  
updated: 2020-09-22  
canonical: https://www.mindstick.com/interview/1278/how-to-create-dynamic-property-with-the-help-of-viewbag-in-asp-dot-net-mvc  
category: "asp.net mvc"  
tags: ["asp.net mvc"]  
reading_time: 1 minute  

---

# How to create dynamic property with the help of ViewBag in Asp.net MVC?

List<string> countries=new List<string>();\
countries.Add("India");\
countries.Add("USA");\
countries.Add("Canada");

ViewBag.Countries=countries; //here Countries is a dynamic property associated with the Viewbag.

## Answers

### Answer by Chris Anderson

List<string> countries=new List<string>();\
countries.Add("India");\
countries.Add("USA");\
countries.Add("Canada");

ViewBag.Countries=countries; //here Countries is a dynamic property associated with the Viewbag.


---

Original Source: https://www.mindstick.com/interview/1278/how-to-create-dynamic-property-with-the-help-of-viewbag-in-asp-dot-net-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
