C#中的基本控制台应用程序是否需要创建数据库?

问题描述 投票:0回答:1

这是我的代码,

Q#1-是否需要为 C# 中的基本控制台应用程序创建数据库?

Q#2-我想知道如何创建 AddEmployee 方法以及其他方法(如 RemoveEmployee 和 FindEmployee)?

我想要的是让用户在 1-3 之间进行选择,之后控制台应用程序不应关闭并询问用户是否要继续,并在从(y/n)应用程序中按 y 时应该再次给出选择并在按“n”时退出。

命名空间UsingLinq

{

class Employee

{
    public int Id { get; set; }
    public string Name { get; set; }
    public string FatherName { get; set; }
}
class Program
{
    List<Employee> lstEmployees = new List<Employee>();

    static void Main()
    {
        while (true)
        {
            Console.WriteLine("1. Add Employee");
            Console.WriteLine("2. Remove Employee");
            Console.WriteLine("3. Find Employee");

            Console.WriteLine("Enter your choice: ");
            int selected = int.Parse(Console.ReadLine());

            switch (selected) {
                case 1:
                    AddEmployee();
                    break;
                case 2:
                    RemoveEmployee();
                    break;
                case 3:
                    FindEmployee();
                    break;
                default:
                    Console.WriteLine("invalid choice!");
                    break;

            }
        }
            
    }

    public static void AddEmployee()
    {

    }

    public static void RemoveEmployee()
    {

    }

    public static void FindEmployee()
    {

    }

}

}

c# database linq methods console-application
1个回答
0
投票

不,不需要为小型控制台应用程序创建数据库。

这是您正在寻找的内容的粗略完成,尽管我假设您希望能够将父亲的名字添加到员工中?希望这能让您朝着正确的方向开始。

https://dotnetfiddle.net/enQJjz

© www.soinside.com 2019 - 2024. All rights reserved.