 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| l |
Dictionaries
|
|
|
/* Create dictionary of squares
and look up and sum entries */
|
|
|
Hashtable Dictionary=new Hashtable(31);
|
|
|
long i;
|
|
|
long sum=0;
|
|
|
int m=int.Parse(this.textBox5.Text);
|
|
|
int n=int.Parse(this.textBox6.Text);
|
|
|
for (i=m;i<=n;i++)
Dictionary.Add(i,(i*i));
|
|
|
MessageBox.Show("Created
dictionary","Created Dictionary",
|
|
|
MessageBoxButtons.OK,MessageBoxIcon.Information);
|
|
|
for (i=m;i<=n;i++)
sum=sum+(long)Dictionary[i];
|
|
|
MessageBox.Show("Sum(dictionary
entry = n*n) from "+m.ToString()+
|
|
" to "+n.ToString()+" =
"+sum.ToString(),"Summed Dictionary",
|
|
|
MessageBoxButtons.OK,
MessageBoxIcon.Information);
|
|