using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
List<string> list = new List<string>();
list.Add("c#");
list.Add("c++");
list.Add("python");
list.Add("java");
var d = new Dictionary<string, int>();
foreach (string s in list) {
if (!d.ContainsKey(s)) {
d.Add(s, 1);
}
}
foreach (var pair in d) {
Console.WriteLine(pair);
}
Console.WriteLine();
foreach (KeyValuePair<string, int> pair in d) {
Console.WriteLine("{0} : {1}", pair.Key, pair.Value);
}
}
}
/*
run:
[c#, 1]
[c++, 1]
[python, 1]
[java, 1]
c# : 1
c++ : 1
python : 1
java : 1
*/