roy roy

roy roy

  • NA
  • 27
  • 0

generics

Dec 21 2008 11:15 PM

Hello.

Your help is very much appreciated.

I created a class (parametersBusinessObject) with a Generic type. This class basically represents a  parameter.

The memebers :

string paramName,

<T> defaultValue,

bool isRequired

 

Then, I tried to use another class(wctl) which contains a list of the parameters.

List< parametersBusinessObject >.

The problem is that I don’t see how I can populate the list with parametersBusinessObject that have a different type. i.e. how would you populate the list with:

“param1”,string, true

“param1”,int, true   ??

 

public class wctl<T> : WebControl

    {

        public class parametersBusinessObject

        {

            string _paramName;

            bool _isRequired;

            T _defaultValue;

 

            public parametersBusinessObject(string paramName, bool isRequired,T defaultValue)

            {

                _paramName = paramName;

                _isRequired = isRequired;

                _defaultValue = defaultValue;

            }

            public string ParamName

            {

                get { return _paramName; }

            }

            public bool IsRequired

            {

                get { return _isRequired; }

            }

            public T DefaultValue

            {

                get { return _defaultValue; }

            }

        }

 

        private List<parametersBusinessObject> _prms;

 

        public List<parametersBusinessObject> Prms

        {

            get { return _prms; }

            set { _prms = value; }

        }

 

Thank you,

Roy

 

 

 


Answers (3)