На самом деле он ни для чего не будет использоваться, но я думаю, что, возможно, я просто неправильно понимаю, как работают эти методы, поэтому я подумал, что, вероятно, стоит прийти сюда. Извините, если это действительно простое решение
Полная ошибка в VS Code была
Не указан аргумент, который соответствует обязательному параметру «имя пользователя» в «Registration.Confirm(int, int)» (CS7036) [Ln 60, столбец 13]», а также встречается в Ln 77, столбец 17
И вот код:
Код: Выделить всё
using System;
using System.ComponentModel;
using System.Threading;
using System.Globalization;
using System.Reflection.PortableExecutable;
using System.Reflection.Metadata.Ecma335;
namespace TestRegister
{
public class Registration
{
public static void Main(string[] args)
{
var today = DateTime.Today;
var myAge = today.Year - 2008;
// this is a comment. this code prints to the console
var myName = "My Name "; // this usually has my actual name but I'm removing it on public forums :)
Console.WriteLine("Hello World!");
Console.WriteLine("This is a test program!");
Console.WriteLine("281 plus 1412 equals:");
Console.WriteLine(281 + 1412);
Console.WriteLine("This test program was written by:");
Console.WriteLine(myName);
Console.WriteLine("And my age is:");
Console.WriteLine(myAge);
EnterUsername();
/* This is the beginning of a multi-line comment
and this is the end of a multi-line comment */
}
public static void EnterUsername()
{
var maximumUserLength = 15;
Console.WriteLine("Enter your Username:");
string username = Console.ReadLine();
if (username.Length > maximumUserLength)
{
Console.WriteLine("Usernames can only be up to 15 characters long. Please try again with a shorter username.");
EnterUsername();
}
else;
EnterAge();
}
public static void EnterAge()
{
var maximumAge = 85;
Console.WriteLine("Enter your age:");
int age = Convert.ToInt32(Console.ReadLine());
if (age > maximumAge)
{
Console.WriteLine("Sorry, you are older than our age limit.");
EnterUsername();
}
else;
Confirm();
}
public static void Confirm(int username, int userAge)
{
Console.WriteLine("Confirm: Your chosen Username is: " + username + " and your current age is: " + userAge + ". (Y/N)");
string ConfirmDetails = Convert.ToString(Console.ReadLine());
if (ConfirmDetails.Contains("y"))
{
Console.WriteLine("Thank you for the information. You have been registered.");
}
else if (ConfirmDetails.Contains("n"))
EnterUsername();
else;
Console.WriteLine("Invalid character.");
Confirm();
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... -parameter