Can I install and install an array in C #?

QUESTION FOR HOME: I need to create a simple shallow game that is read from a CSV file. My data for a specific question is structured as follows: "Question, answer, answer, answer, answer," correct answer ").

We use a series of getters and setters to store all the relevant data for one question object, and I have a problem with the array that I created to store four answers.

In my constructor, I use this code, which, it seems to me, creates an instance of the array of answers in question:

class TriviaQuestionUnit
{
    ...

    const int NUM_ANSWERS = 4;
    string[] m_Answers = new String[NUM_ANSWERS];

    public string[] Answer
    {
        get { return m_Answers[]; }
        set { m_Answers = value[];
    }

    ...

    // Answer array
    public string[] GETAnswer(int index) 
    {
        return m_Questions[index].Answer;
    }

    ...
}

I access getter and setter from my method TriviaQuestionBank, which includes this code:

...

const int NUM_QUESTIONS = 15;
TriviaQuestionUnit[] m_Questions = new TriviaQuestionUnit[NUM_QUESTIONS];

...

// Answer array
public string[] GETAnswer(int index) 
{
    return m_Questions[index].Answer;
}

...

I use StreamReaderto read input lines from my file

...

char delim = ';'; 
String[] inputValues = inputText.Split(delim); 

...

, . , 1 4 inputValues, .

...

for (int i = 0; i < NUM_ANSWERS; i++)                                      
{
    m_Questions[questionCounter].Answer[i] = inputValues[i + 1];    
}

...

Syntax code, value expected getters/setters , m_Answers[NUM_QUESTIONS], can't implicitly convert string to String[].

, -, . , - , .

+4
1

, , : . , , ; googling , .

" ", , . , , , , . , , , .

TriviaQuestionUnit. , 4, , , .

new string[NUM_ANSWERS], ().

, , - . , , :

public string[] Answer

, , ?

m_Answers - "" , , , m_Answers, . , , ?

[] , , . , , ( 0). , ? , ?

!

Indexer has 1 parameter(s) but is invoked with (0) argument(s)

? , [], , , 0, : [0]. , .

, ?

, , [] m_Answers :

public string[] Answer
{
    get { return m_Answers; }
    set { m_Answers = value; }
}

, , set.

, !

+3

All Articles