views:

450

answers:

2

In a SortedDictionary is it possible to change the value of an item ?

+5  A: 

Yes, why not?

sortedDictionary[key] = newValue;
Mehrdad Afshari
+1  A: 

Yes, just use the indexer like this (in C#):

using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        SortedDictionary<int, string> map = 
            new SortedDictionary<int, string>();
        map[1] = "Kevin Hazzard";
        Console.WriteLine( map[1] );
        map[1] = "W. Kevin Hazzard";
        Console.WriteLine( map[1] );
        Console.ReadLine();
    }
}
W. Kevin Hazzard