Generics is very slow. Need help speeding it up

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; }}}
 
T

Torben Laursen

Hi

Problem solved.
It was not the generics code but the 3 party component that I was used
together with the code.
Turns out the component does not like strings with numbers in it.

Sorry Torben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top