Answer» Sir can you explain to me in details what is class,delegate,enum and interface or struct and please can you give me the examples??
It is because I doing now a study for my job purposes someday.And I do calculator program now in C sharp.And here is the error Error1The name 'TOTAL1' does not exist in the current context
Error 2The name 'total1' does not exist in the current context
Error 3The name 'total1' does not exist in the current context
Error 4 The name 'total1'does not exist in the current context
Error 5Expected class, delegate, enum, interface, or struct
Error 6 Expected class, delegate, enum, interface, or struct
And that`s the all errors..
And the code was?using SYSTEM; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void txtDisplay_TextChanged(object sender, EventArgs e) {
}
private void btnOne_Click(object sender, EventArgs e) { txtDisplay.Text = txtDisplay.Text+btnOne.Text; }
private void btnTwo_Click(object sender, EventArgs e) { txtDisplay.Text = txtDisplay.Text + btnTwo.Text; }
private void btnThree_Click(object sender, EventArgs e) { txtDisplay.Text = txtDisplay.Text + btnThree.Text; }
private void btnFour_Click(object sender, EventArgs e) { txtDisplay.Text = txtDisplay.Text + btnFour.Text; }
private void btnFive_Click(object sender, EventArgs e) { txtDisplay.Text = txtDisplay.Text + btnFive.Text; }
private void btnSix_Click(object sender, EventArgs e) { txtDisplay.Text = txtDisplay.Text + btnSix.Text; }
private void btnSeven_Click(object sender, EventArgs e) { txtDisplay.Text = txtDisplay.Text + btnSeven.Text; }
private void btnEight_Click(object sender, EventArgs e) { txtDisplay.Text = txtDisplay.Text + btnEight.Text; }
private void btnNine_Click(object sender, EventArgs e) { txtDisplay.Text = txtDisplay.Text + btnNine.Text; }
private void btnZero_Click(object sender, EventArgs e) { txtDisplay.Text = txtDisplay.Text + btnZero.Text; }
private void btnClear_Click(object sender, EventArgs e) { txtDisplay.Clear(); } double total2=0;
private void btnPlus_Click(object sender, EventArgs e) { total1 = total1 + double.Parse(txtDisplay.Text); txtDisplay.Clear();
plusButtonClicked = true; minusButtonClicked= false;
} }
private void btnEquals_Click(object sender, EventArgs e) { if(plusButtonClicked==true) {
total2=total1+double.Parse(txtDisplay.Text); } else if (minusButtonClicked==true) { total2=total1+double.Parse(txtDisplay.Text); } txtDisplay.Text=total2.ToString(); total1=0; }
BOOL plusButtonClicked = false; bool minusButtonClicked = false; private void btnMinus_Click(object sender, EventArgs e) { total1 = total1 + double.Parse(txtDisplay.Text); txtDisplay.Clear();
plusButtonClicked = true; minusButtonClicked = false; }
}the formatting there is awful... which is probably why you missed this:
Code: [Select]private void btnClear_Click(object sender, EventArgs e) { txtDisplay.Clear(); } double total2=0;
private void btnPlus_Click(object sender, EventArgs e) { total1 = total1 + double.Parse(txtDisplay.Text); txtDisplay.Clear();
plusButtonClicked = true; minusButtonClicked= false;
} } you have the braces that end that function, and then you are declaring a class-level variable (form-level). This could be on purpose... however, the btnPlus_Click ending with two brackets isn't- the second brace ends the class. Therefore I assume your errors are starting right after that second curly brace.
Sir, in first place I am a beginner in C Sharp.And can you explain please further your suggestions about it.
First Can you explain further about my error is on details? And can you point out there in your outlined program or in my program where is the function is,where is the class and everything about that program and the SENTENCES you had at the bottom part of my program??So that I can understand more to it.Sir I am WAITING from then that my asked question in the date of Oct.04,2010, 4:26A.M.About my C# questions.And hoping to be answered.So now it is no replied messages in my inbox.So how it is Sir like that??and hoping to you sir more power!! Quote from: dave_trodeau2000 on October 12, 2010, 12:45:11 AM now it is no replied messages in my inbox.So how it is Sir like that? Contents of this post deleted by Allan
|