vendredi 26 novembre 2021

Beginner Question - Error in Starting Program in VS2022

I'm currently following the Lynda Course "Learning C Sharp" without any prior coding knowledge.

I've completed the first exercise of creating a questionnaire using commands to input and output to console, in the process learning about strings and variables.

The issue I am having is when i moved onto the next exercise and added an if statement to this questionnaire, not only did it fail to run but once i deleted the added code the original functioning program no longer works. I am unable to undo this back to before I added the code. However VS allows me to run the previous functioning program.

Additionally, as I am using VS2022 and the tutorial is using VS2019 I believe, it seems like i am not seeing the comprehensive code with the different brackets and indentations seen in the tutorial.

I'm guessing this is a function that can be turned on and that it is in this hidden formatting that something went wrong?

Would appreciate any help and knowing more about best practices to revert back to previously function code (Autosave feature? Save as periodically? etc?)

My VS2022 Code vs Tutorial VS2019 Code

// See https://aka.ms/new-console-template for more information

Console.WriteLine("What is your name?");
var name = Console.ReadLine();
Console.WriteLine("How old are you?");
var age = Console.ReadLine();
Console.WriteLine("What month were you born in?");
var month = Console.ReadLine ();
Console.WriteLine ("Your name is: {0}", name);
Console.WriteLine("Your age is: {0}", age);
Console.WriteLine("Your month of birth is: {0}", month);

Thanks!

Aucun commentaire:

Enregistrer un commentaire