Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Please explain the class,delegate,enum and interface or struct in C Sharp..??  (Read 7875 times)

0 Members and 1 Guest are viewing this topic.

dave_trodeau2000

    Topic Starter


    Rookie

    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
      Error   1   The name 'total1' does not exist in the current context   

    Error     2   The name 'total1' does not exist in the current context   

    Error    3   The name 'total1' does not exist in the current context

    Error        4      The name 'total1'does not exist in the current context

    Error     5   Expected class, delegate, enum, interface, or struct

    Error        6      Expected class, delegate, enum, interface, or struct


       And that`s the all errors.. :-[



    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    And the code was?
    I was trying to dereference Null Pointers before it was cool.

    dave_trodeau2000

      Topic Starter


      Rookie

      Sir, here is the code!!
      « Reply #2 on: October 01, 2010, 07:11:14 AM »
      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;
             
              }

          }

      BC_Programmer


        Mastermind
      • Typing is no substitute for thinking.
      • Thanked: 1140
        • Yes
        • Yes
        • BC-Programming.com
      • Certifications: List
      • Computer: Specs
      • Experience: Beginner
      • OS: Windows 11
      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.

      I was trying to dereference Null Pointers before it was cool.

      dave_trodeau2000

        Topic Starter


        Rookie

        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.

        dave_trodeau2000

          Topic Starter


          Rookie

          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!!

          Salmon Trout

          • Guest
          now it is no replied messages in my inbox.So how it is Sir like that?

          Contents of this post deleted by Allan
          « Last Edit: November 13, 2010, 04:28:40 AM by Allan »