Avatar of rmmarsh
rmmarsh
Flag for United States of America asked on

Error CS0308: The non-generic type `System.Array' cannot be used with the type arguments

I am getting the following error on the two lines of code:

Error CS0308: The non-generic type `System.Array' cannot be used with the type arguments

How do I fix this?
public Array<double> primitiveConst_, a_, b_, c_;
public Array<bool> monotonicityAdjustments_;

Open in new window

.NET Programming

Avatar of undefined
Last Comment
rmmarsh

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
kaufmed

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
jonnidip

You could use List instead of Array:
public List<double> primitiveConst_, a_, b_, c_;
public List<bool> monotonicityAdjustments_;

primitiveConst_ = new List<double>() { 1, 2, 3 };
a_ = new List<double>() { 4, 5, 6 };
monotonicityAdjustments_ = new List<bool>() { false, false, true };

Open in new window

Regards.
rmmarsh

ASKER
I guess I should have given the code for the whole class... here it is.  I don't understand why I'm getting the error, so if one of you could also explain that, I would appreciate it.
public class CoefficientHolder 
   {
      public CoefficientHolder(int n)
      {
         n_ = n ;
         primitiveConst_ = new Array<double>(n - 1);
         a_ = new Array<double>(n - 1);
         b_ = new Array<double>(n - 1);
         c_ = new Array<double>(n - 1);
         monotonicityAdjustments_ = new Array<bool>(n); 
      }
      
      public virtual void Dispose() {}
      public int n_;
      public Array<double> primitiveConst_, a_, b_, c_;
      public Array<bool> monotonicityAdjustments_;
   };

Open in new window

SOLUTION
Jacques Bourgeois (James Burger)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
kaufmed

I don't understand why I'm getting the error
I showed you why. You have to drop the angle brackets. There is no generic version of the Array class. You can assign an array of any type to the variable that is declared as type Array.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
rmmarsh

ASKER
Thanks...