'print multiple return from void to multiple textboxes in c#
i'm trying to build a question-solving module, so i want to randomly print the "correct answer" data i got from the database, i use a void to get the data, i want to print data directly from return to textbox to easily print data by changing variable places
what i want to do is as below (does not work as it is):
public void qetQuestion()
{
testEntities tE = new testEntities();
var item = tE.Sorus.Where(a => a.soruID == 1).SingleOrDefault();
string queDescription = item.queDescription;
string rightAnswer = item.rightAnswer;
string wrongAnswer1 = item.wrongAnswer1;
string wrongAnswer2 = item.wrongAnswer2;
string wrongAnswer3 = item.wrongAnswer3;
return (queDescription, rightAnswer, wrongAnswer1, wrongAnswer2, wrongAnswer3);
}
private void btnNewQuestion_Click(object sender, EventArgs e)
{
int rightChoice = rnd.Next(4);
if (rightChoice == 0) // A
{
qetQuestion(rTxtqueDescription.Text, txtA.Text, txtB.Text, txtC.Text, txtD.Text)
}
if (rightChoice == 1) // B
{
qetQuestion(rTxtqueDescription.Text, txtB.Text, txtA.Text, txtC.Text, txtD.Text)
}
if (rightChoice == 2) // C
{
qetQuestion(rTxtqueDescription.Text, txtC.Text, txtB.Text, txtA.Text, txtD.Text)
}
if (rightChoice == 3) // D
{
qetQuestion(rTxtqueDescription.Text, txtD.Text, txtB.Text, txtA.Text, txtD.Text)
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
