且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在C#中管理文本文件数据

更新时间:2023-10-14 15:50:04

假设您有每个用户名的唯一代码。



使用C#字典< TKey,TValue> ,并将代码作为键和用户名作为值添加到字典中。



您的字典看起来像:

Assuming, you have a unique code for each username.

Use C# Dictionary<TKey,TValue>, and add you codes as keys and usernames as values into the dictionary.

Your dictionary will look something like:
Key             Value
123             ChrisHD22
846             ChrisCreateBoss
067             Unknown





通过执行此操作,您可以搜索在文本框中输入的密钥并从字典中获取其对应的值。



检查以下链接,了解它的工作原理:

H ttps://msdn.microsoft.com/en-us/library/xfhwa508%28v=vs.110%29.aspx [ ^ ]

http://www.dotnetperls.com/dictionary [ ^ ]


您可以使用与您需要的名称编号匹配的枚举器(枚举)。



ex,

Hi You can use enumerator (enum) which matches name-number which you require.

ex,
public enum usernames
   {
       ChrisHD22= 123,
       ChrisCreateBoss= 846,
       Unknown= 067
   }





一些帮助链接:



HTTP:// ***.com/questions/309333/enum-string-name-from-value [ ^ ]



http://www.csharp-station.com/Tutorial/CSharp/lesson17 [ ^ ]