字符串未显示在控制台中

时间:2015-07-27 07:52:42

标签: printing console

出于某种原因,这并没有显示我在控制台中写的内容 - 它没有在控制台中打印。我可能会对静态的东西感到困惑。另外,当getUserInformation()方法从控制台向声明的变量返回信息时,它是如何变为void的?感谢

    namespace Student_Information
{
    class Program
    {

        static void Main(string[] args)
        {
            string firstName = string.Empty, lastName = string.Empty, birthday = string.Empty;
            getUserInformation();
            printStudentDetails(firstName, lastName, birthday);
        }

        static void getUserInformation()
        {
            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 your bithdate");
            string birthday = Console.ReadLine();
        }

        static void printStudentDetails(string firstName, string lastName, string birthday)
        {
            Console.WriteLine("{0} {1} was born on: {2}", firstName, lastName, birthday);
            Console.ReadLine();
        }
    }
}

1 个答案:

答案 0 :(得分:0)

使用

Console.WriteLine(firstName+" "+lastName+" was born on: "+birthday);