Challenge: Variable Declaration
Complete the code by declaring the variables value_1
and value_2
having values 10
and 20
respectively.
main.cs
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
namespace ConsoleApp
{
internal class Program
{
static void Main(string[] args)
{
// Write code below this line
// Write code above this line
System.Console.WriteLine("Value 1: " + value_1);
System.Console.WriteLine("Value 2: " + value_2);
}
}
}
12345678910111213141516namespace ConsoleApp { internal class Program { static void Main(string[] args) { // Write code below this line // Write code above this line System.Console.WriteLine("Value 1: " + value_1); System.Console.WriteLine("Value 2: " + value_2); } } }
Use the
var
keyword and the assignment operator (=
) for variable declaration.
main.cs
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
namespace ConsoleApp
{
internal class Program
{
static void Main(string[] args)
{
// Write code below this line
var value_1 = 10;
var value_2 = 20;
// Write code above this line
System.Console.WriteLine("Value 1: " + value_1);
System.Console.WriteLine("Value 2: " + value_2);
}
}
}
1234567891011121314151617namespace ConsoleApp { internal class Program { static void Main(string[] args) { // Write code below this line var value_1 = 10; var value_2 = 20; // Write code above this line System.Console.WriteLine("Value 1: " + value_1); System.Console.WriteLine("Value 2: " + value_2); } } }
Var alt klart?
Tak for dine kommentarer!
Sektion 1. Kapitel 9
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat