0
            int ValueOne, ValueTwo, Numchar, Total;
        Console.WriteLine("This Is A Program For doing any Of the four mathematical Proccesses");
        Console.WriteLine("You can Add , substract , Divide And Multiply");
        Console.WriteLine("When Asked Please Type The Values Or The Proccesses You Want.");
        Console.WriteLine("Please Type The First Value");
        ValueOne = Convert.ToInt32((Console.ReadLine()));
        Console.WriteLine("Please Type The Second Value");
        ValueTwo = Convert.ToInt32((Console.ReadLine()));
        Console.WriteLine("Please Enter The Number Of The Proccess/Character You Want Meaning That (1 = +) , (2 = -) , (3 = *) , (4 = /)");
        Numchar = Convert.ToInt32((Console.ReadLine()));
        if ((Numchar) = 1)
            Total = ValueOne + ValueTwo;
        if ((Numchar) = 2)
            Total = ValueOne + ValueTwo;
        if ((Numchar) = 3
            Total = ValueOne * ValueTwo;
                if ((Numchar) = 4
                    Total = ValueOne / ValueTwo; 

This is a console application using c# , What Gives me The Error is : "If ((NumChar) = (number)" I'm a beginner in visual studio and I just started taking the courses

phoog
  • 42,068
  • 6
  • 79
  • 117
GamerGamesGames
  • 71
  • 1
  • 10

3 Answers3

1
if ((Numchar) = 1)

should be

if (Numchar == 1)

= is for assigning a value

== is for comparing values

EDIT: And as the comments point out, you missed the closing parentheses in your 3rd and 4th if statements

if ((Numchar) = 3

should be

if (Numchar = 3)

and drop the parentheses around Numchar, they are pointless

psoshmo
  • 1,490
  • 10
  • 19
0

use == to compare. for example:

if ((Numchar) == 2)
    Total = ValueOne + ValueTwo;

When you use a single equal, you are assigning a value to Numchar, and that new value gets returned (in this case an int)

Looks like you might be used to VB (based on your variable names, etc). Telerik has a nice VB to C# code converter you can use to double-check your results, here:

http://converter.telerik.com/

David J
  • 659
  • 1
  • 9
  • 25
0

You're assigning a value, not comparing it. Use == for comparison

Just Do It
  • 461
  • 1
  • 7
  • 18