using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MethodsExceptions2
{
class Program
{
static void Main(string[] args)
{
GetStudentInformation();
PrintStudentDetails(firstName, lastName,birthDay);
Console.ReadKey();
}
static void GetStudentInformation()
{
Console.WriteLine("Enter the student's first name: ");
string firstName = Console.ReadLine();
Console.WriteLine("Enter the student's last name");
string lastName = Console.ReadLine();
Console.WriteLine("Enter the student's birthday");
string birthDay = Console.ReadLine();
}
static void PrintStudentDetails(string first, string last, string birthday)
{
Console.WriteLine("{0} {1} was born on: {2}", first, last, birthday);
}
}
}
如何在我的方法调用中输入这些值?当我运行该程序时,该线在变量点中空白。我试图用getStudentInfo
方法获取用户输入,然后将其存储在变量中,并将其输入到printStudentInfo
方法中,以格式化并将其写入控制台。如何在调用方法时使用局部变量?
你发布的代码甚至无法编译,所以我不知道你的意思是什么_“当我运行该程序时,该行出现空白_”。你如何运行一个不能编译的程序?最有可能的是,你的问题是几百甚至上千个“我不知道局部变量和类变量之间的区别”的现有问题的重复,但是不可能确定地知道,因为你的代码例子不会做你说的那样。 –