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

rmmarsh
rmmarsh used Ask the Experts™
on
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

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Glanced up at my screen and thought I had coded the Matrix...  Turns out, I just fell asleep on the keyboard.
Most Valuable Expert 2011
Top Expert 2015
Commented:

public Array primitiveConst_, a_, b_, c_;
public Array monotonicityAdjustments_;

primitiveConst_ = new double[5];  // For example

Open in new window

Commented:
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.

Author

Commented:
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

Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Top Expert 2015
Commented:
System.Array is a static class in C#. You cannot use it directly in a declaration.

The proper syntax to declare an array in C# is

public double[] primitiveConst_, a_, b_, c_;
public bool[] monotonicityAdjustments_;

Open in new window

kaufmedGlanced up at my screen and thought I had coded the Matrix...  Turns out, I just fell asleep on the keyboard.
Most Valuable Expert 2011
Top Expert 2015

Commented:
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.

Author

Commented:
Thanks...

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial