Click here to Skip to main content
15,917,709 members
Home / Discussions / C#
   

C#

 
GeneralRe: Job Interview Pin
Anthony Mushrow9-Oct-07 15:03
professionalAnthony Mushrow9-Oct-07 15:03 
AnswerRe: Job Interview Pin
Judah Gabriel Himango9-Oct-07 16:21
sponsorJudah Gabriel Himango9-Oct-07 16:21 
Questionisolating a lib Pin
assmax9-Oct-07 11:55
assmax9-Oct-07 11:55 
QuestionGetting a PropertyGrid to display a value in Hex Pin
melchizedek9-Oct-07 11:04
melchizedek9-Oct-07 11:04 
AnswerRe: Getting a PropertyGrid to display a value in Hex Pin
pmarfleet9-Oct-07 11:38
pmarfleet9-Oct-07 11:38 
GeneralRe: Getting a PropertyGrid to display a value in Hex Pin
visualhint9-Oct-07 14:38
visualhint9-Oct-07 14:38 
GeneralRe: Getting a PropertyGrid to display a value in Hex Pin
melchizedek10-Oct-07 2:18
melchizedek10-Oct-07 2:18 
AnswerRe: Cool Idea Of The Day Pin
eggsovereasy9-Oct-07 10:24
eggsovereasy9-Oct-07 10:24 
GeneralRe: Cool Idea Of The Day Pin
Malcolm Smart9-Oct-07 10:25
Malcolm Smart9-Oct-07 10:25 
GeneralRe: Cool Idea Of The Day Pin
eggsovereasy9-Oct-07 11:06
eggsovereasy9-Oct-07 11:06 
QuestionGet Domain Names on specific IP Address Pin
Davids Maguire9-Oct-07 10:00
Davids Maguire9-Oct-07 10:00 
AnswerRe: Get Domain Names on specific IP Address Pin
Peter Vertes9-Oct-07 10:02
Peter Vertes9-Oct-07 10:02 
AnswerRe: Get Domain Names on specific IP Address Pin
mr_lasseter9-Oct-07 15:36
mr_lasseter9-Oct-07 15:36 
QuestionHow to access this variabel? Pin
Joplinazz9-Oct-07 9:48
Joplinazz9-Oct-07 9:48 
AnswerRe: How to access this variabel? Pin
Anthony Mushrow9-Oct-07 9:52
professionalAnthony Mushrow9-Oct-07 9:52 
The variable 'rightAnswer' is only local to the method getQ()
And you can't access it from anywhere else.

Add a class variable or something, so you'd end up with:

public partial class Form1 : Form
{
private int rightAnswer;

...

public void getQ()
{
Random r = new Random();
int maxRand = 9;
int firstNumber = r.Next(maxRand);
int secondNumber = r.Next(maxRand);
label3.Text = firstNumber + " * " + secondNumber;
rightAnswer = firstNumber * secondNumber;
}

public void button1_Click(object sender, System.EventArgs e)
{
int answer = int.Parse(textBox1.Text);

if (answer == rightAnswer)
{
label4.Text = "Right answer!";
}

...

My current favourite word is: Waffle

Cheese is still good though.

AnswerRe: How to access this variabel? Pin
Scott Dorman9-Oct-07 9:59
professionalScott Dorman9-Oct-07 9:59 
QuestionInstallation System Pin
Ken Mazaika9-Oct-07 9:30
Ken Mazaika9-Oct-07 9:30 
AnswerRe: Installation System Pin
il_masacratore9-Oct-07 21:36
il_masacratore9-Oct-07 21:36 
Question...(object sender, System.EventArgs e) Pin
Imran Adam9-Oct-07 8:43
Imran Adam9-Oct-07 8:43 
AnswerRe: ...(object sender, System.EventArgs e) Pin
Not Active9-Oct-07 8:59
mentorNot Active9-Oct-07 8:59 
GeneralRe: ...(object sender, System.EventArgs e) Pin
Imran Adam9-Oct-07 9:04
Imran Adam9-Oct-07 9:04 
AnswerRe: ...(object sender, System.EventArgs e) Pin
Scott Dorman9-Oct-07 9:49
professionalScott Dorman9-Oct-07 9:49 
GeneralRe: ...(object sender, System.EventArgs e) Pin
Imran Adam9-Oct-07 10:17
Imran Adam9-Oct-07 10:17 
GeneralRe: ...(object sender, System.EventArgs e) Pin
Scott Dorman9-Oct-07 10:27
professionalScott Dorman9-Oct-07 10:27 
QuestionDataGridView HeaderCell Painting Pin
cris34569-Oct-07 7:30
cris34569-Oct-07 7:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.