在控制台应用程序中保存并显示数据 [英] save and show data in console application
本文介绍了在控制台应用程序中保存并显示数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用添加功能通过键盘进行了输入.如何使用存储在add函数中的名称在show函数中显示?
I have taken the input through keyboard using add function. How can I use the name stored in add function to display in a show function?
static void add(employee em)
{
Console.WriteLine("Enter Name");
string name;
name= Console.ReadLine();
name = em.Name;
}
如何将存储在名称变量中的名称用于静态show函数中以显示存储的名称?
[格式化]
How can the name stored in name variable be used in a static show function to display name stored?
[Formatting]
推荐答案
使其成为成员变量,或从方法中将其返回.您将需要使该方法不是静态的以使用成员变量.
Make it a member variable, or return it from the method. You will need to make the method not static to use a member variable.
这篇关于在控制台应用程序中保存并显示数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文