> So I would access it like this
ParentGrouping[System.string, "myitemKey"] = "new value";
OR
ParentGrouping[System.Drawing.Point, "myitemKey"] = new
System.Drawing.Point(0,0);
You can do something like this.
Dictionary<string, MyClass> myclass = new Dictionary<string,
MyClass>();
myclass.Add("one", new MyClass(new System.Drawing.Point(1, 2)));
myclass.Add("two", new MyClass("Hello"));
The complete example (a console app):
using System;
using System.Collections.Generic;
using System.Text;
namespace Generics_Dictionary
{
class MyClass
{
private System.Drawing.Point _point = new System.Drawing.Point();
private string _MyText = "";
private bool EmptyText = true;
public MyClass(System.Drawing.Point point)
{
_point = point;
}
public MyClass(string MyText)
{
this.EmptyText = false;
this._MyText = MyText;
}
public string MyText
{
get
{
return this._MyText;
}
set
{
this.EmptyText = false;
this._MyText = value;
}
}
public System.Drawing.Point MyPoint
{
get
{
return this._point;
}
set
{
this._point = value;
}
}
public bool IsTextEmpty
{
get
{
return this.EmptyText;
}
}
}
class Program
{
public Program()
{
Dictionary<string, MyClass> myclass = new Dictionary<string,
MyClass>();
myclass.Add("one", new MyClass(new System.Drawing.Point(1, 2)));
myclass.Add("two", new MyClass("Hello"));
foreach (KeyValuePair<string, MyClass> cls in myclass)
{
if (!cls.Value.MyPoint.IsEmpty)
System.Console.WriteLine("Text : " + cls.Value.MyPoint.X
+ "." + cls.Value.MyPoint.Y);
if (!cls.Value.IsTextEmpty)
System.Console.WriteLine("Text : " + cls.Value.MyText);
}
System.Console.ReadKey();
}
static void Main(string[] args)
{
new Program();
}
}
}
Regards,
Lars-Inge Tnnessen