Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用结构在列表中存储信息?_C#_Winforms_List_Visual Studio 2008_Struct - Fatal编程技术网

C# 如何使用结构在列表中存储信息?

C# 如何使用结构在列表中存储信息?,c#,winforms,list,visual-studio-2008,struct,C#,Winforms,List,Visual Studio 2008,Struct,我想让用户在Windows窗体中为应用程序创建一个新帐户。我认为,最好将所有相关的帐户信息存储在一个结构中,并使用一个列表来存储每个帐户。然后,我会检查用户名和密码框中插入的每个字符串(在登录屏幕上),并将其与列表中每个元素的每个字符串进行比较,直到找到正确的匹配项(用户名和密码) 到目前为止我所做的: struct Birth { int day; int month; int year; } struct acc

我想让用户在Windows窗体中为应用程序创建一个新帐户。我认为,最好将所有相关的帐户信息存储在一个结构中,并使用一个列表来存储每个帐户。然后,我会检查用户名和密码框中插入的每个字符串(在登录屏幕上),并将其与列表中每个元素的每个字符串进行比较,直到找到正确的匹配项(用户名和密码)

到目前为止我所做的:

    struct Birth
    {
        int day;
        int month;
        int year;
    }
    struct accounts
    {
        char[] last_name;
        char[] first_name;
        char[] username;
        char[] password;
        int[] telephone_number;
        Birth birth_date;
    };
    List<accounts> utilizatori = new List<accounts>();
struct出生
{
国际日;
整月;
国际年;
}
结构帐户
{
char[]姓;
char[]名字;
char[]用户名;
char[]密码;
int[]电话号码;
出生日期;
};
列表实用程序i=新列表();

我以前从未同时使用过结构和列表。如何将新元素添加到结构的每个字段的列表中?另外,如何保存列表中存储的信息,以便下次打开项目时,不必再次创建相同的帐户?

阅读structs的技术指南:

  • 它在逻辑上表示单个值,类似于基元类型 (整数、双精度等)
  • 它的实例大小小于16字节
  • 它是不变的
  • 它不必经常装箱

您的使用似乎违反了前三个条件