T
Torben Laursen
Hi
I have a small generics class that I use to store values. The code is below.
My problem is that if I use the class to store a string like:
cItem<string> Test = new cItem<string>(" ", " ", " ");
Then code like the line below becomes very slow:
string temp = Test.Value;
If I have an array with 100 items looping over it takes around 30 seconds
However if I use the class to store int or double there are no problems.
Can anyone help me rewriting the code so I can use the class with string?
PS I use VS2005
Thanks Torben
public class cItem<TemplateType>{
private TemplateType value_;
private string name;
private string xmlname;
private string units;
public cItem(string XMLname, string Name, string Units){
xmlname = XMLname;
name = Name;
units = "[" + Units + "]";}
public string Name{
get { return name; }}
public string XMLname{
get { return xmlname; }}
public string Unit{
get { return units; }}
public TemplateType Value{
get { return value_; }
set { value_ = value; }}}
I have a small generics class that I use to store values. The code is below.
My problem is that if I use the class to store a string like:
cItem<string> Test = new cItem<string>(" ", " ", " ");
Then code like the line below becomes very slow:
string temp = Test.Value;
If I have an array with 100 items looping over it takes around 30 seconds
However if I use the class to store int or double there are no problems.
Can anyone help me rewriting the code so I can use the class with string?
PS I use VS2005
Thanks Torben
public class cItem<TemplateType>{
private TemplateType value_;
private string name;
private string xmlname;
private string units;
public cItem(string XMLname, string Name, string Units){
xmlname = XMLname;
name = Name;
units = "[" + Units + "]";}
public string Name{
get { return name; }}
public string XMLname{
get { return xmlname; }}
public string Unit{
get { return units; }}
public TemplateType Value{
get { return value_; }
set { value_ = value; }}}