2. Edit the Program.cs file as shown below.
static void Main(string[] args)
{
string favoritePet = "Cat";
Console.WriteLine("My favorite pet is a cat.");
if (favoritePet == "Cat")
Console.WriteLine("And it says: Meow!");
Console.WriteLine("Press any key to continue....");
Console.ReadLine();
}
4. Thank you.
The If statement is used to add condition to a piece of code. Its syntax is:
if()
{
//code }
condition – could be anything that would result in a true or false. It only runs the code inside its braces when the condition is true.
No comments:
Post a Comment