M
MM
Hi,
I am very new to C# so please feel free to point out bad style/practice
in code below. Specifically however, I can't seem to return an
enumerator - I get a StackOverflowException and don't have any idea why?
Here's brief code:-
using System;
using System.Collections;
namespace Bent.Params
{
/// <summary>
/// This namespace contains the param dictionary and
/// the other neccessary info to generate the NC code file.
/// </summary>
public class BentParams
{
// Holds all the params
private Hashtable param_dict;
public BentParams()
{
// Init to defaults
// Note that most are bullshit, but all capitalised are required.
this.param_dict = new Hashtable();
this.param_dict.Add("W", ""); // Prog no in machine
this.param_dict.Add("WN", ""); // PART NAME
this.param_dict.Add("NP", 0); // Qty?
this.param_dict.Add("T", 0.0F); // THICKNESS
this.param_dict.Add("QN", 0); // MATERIAL ID
this.param_dict.Add("S", 0); // Tensile
this.param_dict.Add("SQ", 0); // Speed position
this.param_dict.Add("PN", 0); // PUNCH NO
this.param_dict.Add("PR", 0.0F);// Punch radius
// and about another 100 odd entries
}
public IDictionaryEnumerator GetEnumerator()
{
try
{
return this.GetEnumerator();
}
catch (Exception e)
{
Console.WriteLine(e);
return null;
}
}
}
}
When I call GetEnumerator it throws the StackOverflowException. Any
ideas? Also is the constructor okay? Basically I want to setup a
dictionary (which always has same keys) and apply a default set of
values which can be changed as needed. Thanks for the help. matthew.
I am very new to C# so please feel free to point out bad style/practice
in code below. Specifically however, I can't seem to return an
enumerator - I get a StackOverflowException and don't have any idea why?
Here's brief code:-
using System;
using System.Collections;
namespace Bent.Params
{
/// <summary>
/// This namespace contains the param dictionary and
/// the other neccessary info to generate the NC code file.
/// </summary>
public class BentParams
{
// Holds all the params
private Hashtable param_dict;
public BentParams()
{
// Init to defaults
// Note that most are bullshit, but all capitalised are required.
this.param_dict = new Hashtable();
this.param_dict.Add("W", ""); // Prog no in machine
this.param_dict.Add("WN", ""); // PART NAME
this.param_dict.Add("NP", 0); // Qty?
this.param_dict.Add("T", 0.0F); // THICKNESS
this.param_dict.Add("QN", 0); // MATERIAL ID
this.param_dict.Add("S", 0); // Tensile
this.param_dict.Add("SQ", 0); // Speed position
this.param_dict.Add("PN", 0); // PUNCH NO
this.param_dict.Add("PR", 0.0F);// Punch radius
// and about another 100 odd entries
}
public IDictionaryEnumerator GetEnumerator()
{
try
{
return this.GetEnumerator();
}
catch (Exception e)
{
Console.WriteLine(e);
return null;
}
}
}
}
When I call GetEnumerator it throws the StackOverflowException. Any
ideas? Also is the constructor okay? Basically I want to setup a
dictionary (which always has same keys) and apply a default set of
values which can be changed as needed. Thanks for the help. matthew.