简体   繁体   中英

How to run this C# code. using Visual Studio

the code is as follows

static void main(string[] args)
{
   Int num = 10;
   Int num = 20;
   If (10 > 20);
   {
      return;
   }
   Console.WriteLine("10 > 20");
}

basically what I am trying to do is get the code to run to get the output of the program in the command window of visual studio

bunch of things:

  1. as int num is defined twice
    • rename the second int to num2
  2. Int and If should be int and if
  3. remove the ; after the if(10 > 20) line
    • also replace the 10 > 20 with num > num2 to make the first two assignments actually useful

you are defined variable num two times

static void main(string[] args)
{
Int num1 = 10;
Int num2 = 20;
If (10 > 20)
{return;}
Console.WriteLine("10 > 20");

You define the variable num twice. Maybe you can define two variables num1 and num2 to store them.

int num1 = 10;
int num2 = 20;

Do you want to compare two int numbers? If so, you can refer to the following statement.

if(num1 > num2)
{
    //...
}

Besides, you want to print "10 > 20" , rather than "10 < 20" ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM