P
P
Pan Propan2014-11-18 11:48:28
visual studio
Pan Propan, 2014-11-18 11:48:28

How to properly declare variables in Visual Studio 2013?

I'm learning to program in Visual Studio according to the official lessons .
In lesson 11, the task is described, I wrote the following code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Example_11._1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Dim num1, num2, difference, product, quotient, As Single;
            num1 = textBox1.Text;
            num2 = textBox2.Text;
            sum=num1+num2;
            difference=num1-num2;
            product = num1 * num2;
            quotient=num1/num2;
            label1.Text=sum;
            label2.Text=difference;
            label3.Text = product;
            label4.Text = quotient;
        }
    }
}

An error is thrown while compiling,
Error 1 For, using, fixed and declaration statements cannot use more than one type

Help me figure out what's wrong.
I understand the problem with the declaration of variables
Dim num1, num2, difference, product, quotient, As Single;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
suslik2015, 2014-11-18
@suslik2015

Your "official lessons" are in BASIC, but you write in C#. different syntax. In C#, variables are declared like this:
int num1, num2, difference, product, quotient;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question