How to declare an array of 96 double values inside a Form class in VS2019 with C#

Carlos Barberis 0 Reputation points
2023-04-11T19:15:31.6633333+00:00

I am very new to C# and VS 2019 most of my coding is typically in C and I am trying to create a program using VS2019 Winforms in C# where I need to declare a named array of 96 doubles as shown below inside a class Form so its values are accessible within the form. I have tried various ways but obviously I am lost here.

Here is my array from C: (obviously I did not put all the 96 values here)

#define E96_ARRAY_ZIZE 96
double E96ser[E96_ARRAY_ZIZE] = { 1.00, 1.02, 1.05, 1.07, 1.10, 1.13, 1.15, 1.18, 1.21,  1.62, 1.65, 1.69, 1.74,,,,,,,,,,,,,,,}

// I have tried things like:
public double E96ser = new double[96] {n,n,n,n,n,n,n,n,n,.......n};

but that gives me all kind of errors.

Thank you all for any suggestions or help!

Developer technologies | C#
{count} votes

2 answers

Sort by: Most helpful
  1. RLWA32 49,536 Reputation points
    2023-04-11T20:07:31.07+00:00

    Reading documentation is always helpful. Take a look at Array Initialization.

    0 comments No comments

  2. Anonymous
    2023-04-12T08:19:06.63+00:00

    Hi @Carlos Barberis , Welcome to Microsoft Q&A, you could try the following code to get what you wanted.

    You can't use #define E96_ARRAY_ZIZE 96 in winform;

    You can define a value of 96, or create it directly.

    //private const int E96_ARRAY_SIZE = 96;
    // private double[] E96ser = new double[E96_ARRAY_SIZE]{};
    private double[] E96ser = new double[96]
        {1.00, 1.02, 1.05, 1.07, 1.10,...};
    

    enter image description here

    Best Regards,

    Jiale


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.