---
title: "How to populate a list inside a dictionary?"  
description: "How to populate a list inside a dictionary?"  
author: "Anonymous User"  
published: 2013-12-16  
updated: 2013-12-16  
canonical: https://www.mindstick.com/forum/1781/how-to-populate-a-list-inside-a-dictionary  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# How to populate a list inside a dictionary?

I have a [dictionary](https://www.mindstick.com/articles/1500/hashtable-and-dictionary-in-c-sharp) that needs to be [populate](https://www.mindstick.com/blog/60/populate-records-in-second-listbox-according-to-the-selection-in-first-list-box) with a list. The [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) below does not work. How would I [fix](https://yourviews.mindstick.com/view/80763/donald-trump-ki-jeet-fix-hai) it?

clientinfo.cs

[public](https://www.mindstick.com/blog/11097/java-access-modifiers-the-public-and-the-private-modifiers) Dictionary<[int](https://www.mindstick.com/forum/159137/how-to-convert-date-int-to-date-in-sql), List<[string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp)>> [Languages](https://yourviews.mindstick.com/story/1463/some-oldest-languages-in-the-world-still-spoken) { get; set; }

## main.cs

```
var ClientsData = new List<MapModel.ClientInfo> { }   ClientsData.Add(new
MapModel.ClientInfo { Id = IDCounterDoctors, Languages = new Dictionary<int,
List<string>>()});  
ClientsData[0].Languages.Add(2376, ["english",
"french"]); // issue is here
```

## Replies

### Reply by Pravesh Singh

Hi Ben,\

Your initialization of list is wrong. Also make sure your languages property is initialized

ClientsData[0].Languages = new Dictionary<int,List<string>>();

ClientsData[0].Languages.Add(2376,new List<string>(){ "english", "french"});


---

Original Source: https://www.mindstick.com/forum/1781/how-to-populate-a-list-inside-a-dictionary

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
