namespace ConsoleApp124
{
internal class Program
{
public static void GoodsPutInStorageInterface()
{
Console.ForegroundColor = ConsoleColor.Red;
Console.BackgroundColor = ConsoleColor.Blue;
Console.WriteLine(" 商品入库 ");
Console.ForegroundColor = ConsoleColor.Black;
Console.BackgroundColor = ConsoleColor.Cyan;
Console.Write("商品编号");
Console.BackgroundColor = ConsoleColor.White;
Console.WriteLine(" ");
Console.ForegroundColor = ConsoleColor.Black;
Console.BackgroundColor = ConsoleColor.Cyan;
Console.Write("商品名称");
Console.BackgroundColor = ConsoleColor.White;
Console.WriteLine(" ");
Console.ForegroundColor = ConsoleColor.Black;
Console.BackgroundColor = ConsoleColor.Cyan;
Console.Write("商品规格");
Console.BackgroundColor = ConsoleColor.White;
Console.WriteLine(" ");
Console.ForegroundColor = ConsoleColor.Black;
Console.BackgroundColor = ConsoleColor.Cyan;
Console.Write("商品价格");
Console.BackgroundColor = ConsoleColor.White;
Console.WriteLine(" ");
Console.ForegroundColor = ConsoleColor.Black;
Console.BackgroundColor = ConsoleColor.Cyan;
Console.Write("商品数量");
Console.BackgroundColor = ConsoleColor.White;
Console.WriteLine(" ");
Console.ForegroundColor = ConsoleColor.Red;
Console.BackgroundColor = ConsoleColor.Blue;
Console.WriteLine(" 保存\t取消 ");
Console.ForegroundColor = ConsoleColor.White;
Console.BackgroundColor = ConsoleColor.Black;
Console.WriteLine();
}
public static void GoodsInPutInfo()
{
Console.Write("请输入商品编号:");
string GoodsNum = Console.ReadLine();
Console.Write("请输入商品名称:");
string GoodsName = Console.ReadLine();
Console.Write("请输入商品规格:");
string GoodsSpeci = Console.ReadLine();
Console.Write("请输入商品价格:");
string GoodsNPrice = Console.ReadLine();
Console.Write("请输入商品数量:");
string GoodsQuantity = Console.ReadLine();
Console.WriteLine();
}
public static void GoodsOutputStorage()
{
Console.BackgroundColor = ConsoleColor.Blue;
Console.WriteLine(" 商品入库 ");
Console.BackgroundColor = ConsoleColor.White;
Console.ForegroundColor = ConsoleColor.Black;
string GoodsNum = "phone001";
Console.WriteLine("商品编号: "+GoodsNum+" ");
string GoodsName = "华为P30 Pro";
Console.WriteLine("商品名称: " + GoodsName + " ");
string GoodsSpeci = "8*128";
Console.WriteLine("商品规格: " + GoodsSpeci + " ");
string GoodsNprice = "5000";
Console.WriteLine("商品价格: " + GoodsNprice + " ");
string GoodsQuantity = "100";
Console.WriteLine("商品数量: " + GoodsQuantity + " ");
Console.ForegroundColor = ConsoleColor.Red;
Console.BackgroundColor = ConsoleColor.Blue;
Console.WriteLine(" 保存\t取消 ");
}
static void Main(string[] args)
{
Program.GoodsPutInStorageInterface();
Program.GoodsInPutInfo();
Program.GoodsOutputStorage();
Console.ReadLine();
}
}
}
根据题目要求要做三个界面:我用三个方法GoodsPutInStorageInterface、GoodsInPutInfo、GoodsOutputStorage做了这三个界面,分别是商品入库界面、输入商品信息界面、商品出库界面。
请问一下:一般在方法里面声明的变量。当方法结束后,变量就会被销毁。然而GoodsInPutInfo方法和GoodsOutputStorage方法是用一个变量,请问一下有什么办法可以让这个变量可以多次调用,而不是在本方法里面使用一次就销毁?