欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#實(shí)現(xiàn)基于鏈表的內(nèi)存記事本實(shí)例

 更新時(shí)間:2015年07月16日 12:33:22   作者:宋勇野  
這篇文章主要介紹了C#實(shí)現(xiàn)基于鏈表的內(nèi)存記事本,實(shí)例分析了C#基于鏈表實(shí)現(xiàn)的記事本功能,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了C#實(shí)現(xiàn)基于鏈表的內(nèi)存記事本。分享給大家供大家參考。具體如下:

User模型:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
 public class User
 {
  private string username;
  public string Username
  {
   get { return username; }
   set { username = value; }
  }
  private string sex;
  public string Sex
  {
   get { return sex; }
   set { sex = value; }
  }
  private string age;
  public string Age
  {
   get { return age; }
   set { age = value; }
  }
  private string phone;
  public string Phone
  {
   get { return phone; }
   set { phone = value; }
  }
 }
}

程序的靈魂Controller:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace ConsoleApplication1
{
 public class Controller
 {
  private ArrayList a = new ArrayList();
  public ArrayList A
  {
   get { return a; }
   set { a = value; }
  }
  public void add(User user) 
  {
   A.Add(user);
  }
  public void delete(User user) 
  {
   if (A.Contains(user))
   {
    A.Remove(user);
   }
   else
   {
    Console.WriteLine("用戶不存在!");
   }
  }
  public ArrayList select(ArrayList a) 
  {
   return a;
  }
  public User search(string username)
  {
   foreach(User user in A)
   {
    if (user.Username == username)
    {
     return user;
    }
   }
   return null;
  }
 }
}

Program.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace ConsoleApplication1
{
 class Program
 {
  static void Main(string[] args)
  {
   Controller controller = new Controller();
   while (true)
   {
    Console.WriteLine("請(qǐng)輸入您的操作:");
    Console.WriteLine("1,增加用戶");
    Console.WriteLine("2,刪除用戶");
    Console.WriteLine("3,瀏覽用戶");
    Console.WriteLine("4,退出");
    string input = Console.ReadLine();
    if(input=="1")
    {
     User user = new User();
     Console.WriteLine("用戶姓名:");
     user.Username = Console.ReadLine();
     Console.WriteLine("用戶姓別:");
     user.Sex = Console.ReadLine();
     Console.WriteLine("用戶年齡:");
     user.Age = Console.ReadLine();
     Console.WriteLine("電話號(hào)碼:");
     user.Phone = Console.ReadLine();
     controller.add(user);
    }
    if(input=="2")
    {
     Console.WriteLine("請(qǐng)輸入用戶姓名");
     string username = Console.ReadLine();
     if (controller.search(username)!=null)
     {
      User user = controller.search(username);
      controller.delete(user);
     }
     else
     {
      Console.WriteLine("該用戶不存在!");
     }
    }
    if(input=="3")
    {
     foreach(User user in controller.A )
     {
      Console.WriteLine(user.Username);
     }
    }
   }
  }
 }
}

希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • C#向數(shù)據(jù)庫中插入或更新null空值與延遲加載lazy

    C#向數(shù)據(jù)庫中插入或更新null空值與延遲加載lazy

    這篇文章介紹了C#向數(shù)據(jù)庫中插入或更新null空值與延遲加載lazy,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-05-05
  • 使用MSScriptControl 在 C# 中讀取json數(shù)據(jù)的方法

    使用MSScriptControl 在 C# 中讀取json數(shù)據(jù)的方法

    下面小編就為大家?guī)硪黄褂肕SScriptControl 在 C# 中讀取json數(shù)據(jù)的方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-01-01
  • C#?winform?窗體控件跨線程訪問的實(shí)現(xiàn)

    C#?winform?窗體控件跨線程訪問的實(shí)現(xiàn)

    在做winform開發(fā)時(shí),如果在子線程中去設(shè)置主線程中UI控件的屬性,會(huì)出現(xiàn)“跨線程調(diào)用異常”,本文就來介紹一下C#?winform?窗體控件跨線程訪問的實(shí)現(xiàn),感興趣的可以了解一下
    2023-12-12
  • C# wpf解決Popup彈出位置異常問題解決

    C# wpf解決Popup彈出位置異常問題解決

    本文主要介紹了C# wpf解決Popup彈出位置異常問題解決,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-10-10
  • C#實(shí)現(xiàn)Socket服務(wù)器及多客戶端連接的方式

    C#實(shí)現(xiàn)Socket服務(wù)器及多客戶端連接的方式

    這篇文章介紹了C#實(shí)現(xiàn)Socket服務(wù)器及多客戶端連接的方式,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-01-01
  • C#實(shí)現(xiàn)FTP上傳文件的方法

    C#實(shí)現(xiàn)FTP上傳文件的方法

    這篇文章介紹了C#實(shí)現(xiàn)FTP上傳文件的方法,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-04-04
  • C#版免費(fèi)離線人臉識(shí)別之虹軟ArcSoft?V3.0(推薦)

    C#版免費(fèi)離線人臉識(shí)別之虹軟ArcSoft?V3.0(推薦)

    本文只是簡(jiǎn)單介紹了如何使用虹軟的離線SDK,進(jìn)行人臉識(shí)別的方法,并且是圖片的方式,本地離線識(shí)別最大的好處就是沒有延遲,識(shí)別結(jié)果立馬呈現(xiàn),對(duì)C#離線人臉識(shí)別虹軟相關(guān)知識(shí)感興趣的朋友一起看看吧
    2021-12-12
  • Unity 實(shí)現(xiàn)鼠標(biāo)滑過UI時(shí)觸發(fā)動(dòng)畫的操作

    Unity 實(shí)現(xiàn)鼠標(biāo)滑過UI時(shí)觸發(fā)動(dòng)畫的操作

    這篇文章主要介紹了Unity 實(shí)現(xiàn)鼠標(biāo)滑過UI時(shí)觸發(fā)動(dòng)畫的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2021-04-04
  • 詳解C#對(duì)路徑...的訪問被拒絕解決過程

    詳解C#對(duì)路徑...的訪問被拒絕解決過程

    這篇文章主要介紹了詳解C#對(duì)路徑...的訪問被拒絕解決過程,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-12-12
  • C#如何打開并讀取usb的文件目錄

    C#如何打開并讀取usb的文件目錄

    這篇文章主要介紹了用C#語言實(shí)現(xiàn)打開并讀取usb的文件目錄,但是實(shí)現(xiàn)此功能要注意一點(diǎn)必須在u盤插入才能接受到信息,需要的朋友可以參考下
    2015-07-07

最新評(píng)論