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

C#實現(xiàn)簡單串口通訊實例

 更新時間:2022年02月17日 12:16:23   作者:未來無限  
這篇文章主要為大家詳細介紹了C#實現(xiàn)簡單串口通訊的方法,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了C#實現(xiàn)簡單串口通訊的具體代碼,供大家參考,具體內容如下

參數(shù)設置界面代碼:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;

namespace ComDemo
{
? ? public partial class ComSet : Form
? ? {
? ? ? ? public ComSet()
? ? ? ? {
? ? ? ? ? ? InitializeComponent();
? ? ? ? }

? ? ? ? private void ComSet_Load(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? //串口
? ? ? ? ? ? string[] ports = SerialPort.GetPortNames();
? ? ? ? ? ? foreach (string port in ports)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? cmbPort.Items.Add(port);
? ? ? ? ? ? }
? ? ? ? ? ? cmbPort.SelectedIndex = 0;

? ? ? ? ? ? //波特率
? ? ? ? ? ? cmbBaudRate.Items.Add("110");
? ? ? ? ? ? cmbBaudRate.Items.Add("300");
? ? ? ? ? ? cmbBaudRate.Items.Add("1200");
? ? ? ? ? ? cmbBaudRate.Items.Add("2400");
? ? ? ? ? ? cmbBaudRate.Items.Add("4800");
? ? ? ? ? ? cmbBaudRate.Items.Add("9600");
? ? ? ? ? ? cmbBaudRate.Items.Add("19200");
? ? ? ? ? ? cmbBaudRate.Items.Add("38400");
? ? ? ? ? ? cmbBaudRate.Items.Add("57600");
? ? ? ? ? ? cmbBaudRate.Items.Add("115200");
? ? ? ? ? ? cmbBaudRate.Items.Add("230400");
? ? ? ? ? ? cmbBaudRate.Items.Add("460800");
? ? ? ? ? ? cmbBaudRate.Items.Add("921600");
? ? ? ? ? ? cmbBaudRate.SelectedIndex = 5;

? ? ? ? ? ? //數(shù)據(jù)位
? ? ? ? ? ? cmbDataBits.Items.Add("5");
? ? ? ? ? ? cmbDataBits.Items.Add("6");
? ? ? ? ? ? cmbDataBits.Items.Add("7");
? ? ? ? ? ? cmbDataBits.Items.Add("8");
? ? ? ? ? ? cmbDataBits.SelectedIndex = 3;

? ? ? ? ? ? //停止位
? ? ? ? ? ? cmbStopBit.Items.Add("1");
? ? ? ? ? ? cmbStopBit.SelectedIndex = 0;

? ? ? ? ? ? //佼驗位
? ? ? ? ? ? cmbParity.Items.Add("無");
? ? ? ? ? ? cmbParity.SelectedIndex = 0;
? ? ? ? }

? ? ? ? private void bntOK_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? //以下4個參數(shù)都是從窗體MainForm傳入的
? ? ? ? ? ? MainForm.strProtName = cmbPort.Text;
? ? ? ? ? ? MainForm.strBaudRate = cmbBaudRate.Text;
? ? ? ? ? ? MainForm.strDataBits = cmbDataBits.Text;
? ? ? ? ? ? MainForm.strStopBits = cmbStopBit.Text;
? ? ? ? ? ? DialogResult = DialogResult.OK;
? ? ? ? }

? ? ? ? private void bntCancel_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? DialogResult = DialogResult.Cancel;
? ? ? ? }
? ? }
}

主界面代碼:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
using System.IO;
using System.Threading;

namespace ComDemo
{
? ? public partial class MainForm : Form
? ? {
? ? ? ? public MainForm()
? ? ? ? {
? ? ? ? ? ? InitializeComponent();
? ? ? ? }
? ? ? ? private Thread getRecevice;
? ? ? ? protected Boolean stop = false;
? ? ? ? protected Boolean conState = false;
? ? ? ? private StreamReader sRead;
? ? ? ? string strRecieve;
? ? ? ? bool bAccpet = false;

? ? ? ? SerialPort sp = new SerialPort();//實例化串口通訊類
? ? ? ? //以下定義4個公有變量,用于參數(shù)傳遞
? ? ? ? public static string strProtName = "";
? ? ? ? public static string strBaudRate = "";
? ? ? ? public static string strDataBits = "";
? ? ? ? public static string strStopBits = "";

? ? ? ? private void MainForm_Load(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? groupBox1.Enabled = false;
? ? ? ? ? ? groupBox2.Enabled = false;
? ? ? ? ? ? this.toolStripStatusLabel1.Text = "端口號:端口未打開 | ";
? ? ? ? ? ? this.toolStripStatusLabel2.Text = "波特率:端口未打開 | ";
? ? ? ? ? ? this.toolStripStatusLabel3.Text = "數(shù)據(jù)位:端口未打開 | ";
? ? ? ? ? ? this.toolStripStatusLabel4.Text = "停止位:端口未打開 | ";
? ? ? ? ? ? this.toolStripStatusLabel5.Text = "";
? ? ? ? }
? ? ? ? //串口設計
? ? ? ? private void btnSetSP_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? timer1.Enabled = false;
? ? ? ? ? ? sp.Close();
? ? ? ? ? ? ComSet dlg = new ComSet();
? ? ? ? ? ? if (dlg.ShowDialog() == DialogResult.OK)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? sp.PortName = strProtName;//串口號
? ? ? ? ? ? ? ? sp.BaudRate = int.Parse(strBaudRate);//波特率
? ? ? ? ? ? ? ? sp.DataBits = int.Parse(strDataBits);//數(shù)據(jù)位
? ? ? ? ? ? ? ? sp.StopBits = (StopBits)int.Parse(strStopBits);//停止位
? ? ? ? ? ? ? ? sp.ReadTimeout = 500;//讀取數(shù)據(jù)的超時時間,引發(fā)ReadExisting異常
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? //打開/關閉串口
? ? ? ? private void bntSwitchSP_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? if (bntSwitchSP.Text == "打開串口")
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if (strProtName != "" && strBaudRate != "" && strDataBits != "" && strStopBits != "")
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? try
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? if (sp.IsOpen)
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? sp.Close();
? ? ? ? ? ? ? ? ? ? ? ? ? ? sp.Open();//打開串口
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? sp.Open();//打開串口
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? bntSwitchSP.Text = "關閉串口";
? ? ? ? ? ? ? ? ? ? ? ? groupBox1.Enabled = true;
? ? ? ? ? ? ? ? ? ? ? ? groupBox2.Enabled = true;
? ? ? ? ? ? ? ? ? ? ? ? this.toolStripStatusLabel1.Text = "端口號:" + sp.PortName + " | ";
? ? ? ? ? ? ? ? ? ? ? ? this.toolStripStatusLabel2.Text = "波特率:" + sp.BaudRate + " | ";
? ? ? ? ? ? ? ? ? ? ? ? this.toolStripStatusLabel3.Text = "數(shù)據(jù)位:" + sp.DataBits + " | ";
? ? ? ? ? ? ? ? ? ? ? ? this.toolStripStatusLabel4.Text = "停止位:" + sp.StopBits + " | ";
? ? ? ? ? ? ? ? ? ? ? ? this.toolStripStatusLabel5.Text = "";

? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? catch (Exception ex)
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? MessageBox.Show("錯誤:" + ex.Message, "C#串口通信");
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? MessageBox.Show("請先設置串口!", "RS232串口通信");
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? else
? ? ? ? ? ? {
? ? ? ? ? ? ? ? timer1.Enabled = false;
? ? ? ? ? ? ? ? timer2.Enabled = false;
? ? ? ? ? ? ? ? bntSwitchSP.Text = "打開串口";
? ? ? ? ? ? ? ? if (sp.IsOpen)
? ? ? ? ? ? ? ? ? ? sp.Close();
? ? ? ? ? ? ? ? groupBox1.Enabled = false;
? ? ? ? ? ? ? ? groupBox2.Enabled = false;
? ? ? ? ? ? ? ? this.toolStripStatusLabel1.Text = "端口號:端口未打開 | ";
? ? ? ? ? ? ? ? this.toolStripStatusLabel2.Text = "波特率:端口未打開 | ";
? ? ? ? ? ? ? ? this.toolStripStatusLabel3.Text = "數(shù)據(jù)位:端口未打開 | ";
? ? ? ? ? ? ? ? this.toolStripStatusLabel4.Text = "停止位:端口未打開 | ";
? ? ? ? ? ? ? ? this.toolStripStatusLabel5.Text = "";
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? //發(fā)送數(shù)據(jù)
? ? ? ? private void bntSendData_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? if (sp.IsOpen)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? try
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? sp.Encoding = System.Text.Encoding.GetEncoding("GB2312");
? ? ? ? ? ? ? ? ? ? sp.Write(txtSend.Text);//發(fā)送數(shù)據(jù)
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? catch (Exception ex)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? MessageBox.Show("錯誤:" + ex.Message);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? else
? ? ? ? ? ? {
? ? ? ? ? ? ? ? MessageBox.Show("請先打開串口!");
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? //選擇文件
? ? ? ? private void btnOpenFile_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? OpenFileDialog open = new OpenFileDialog();
? ? ? ? ? ? open.InitialDirectory = "c\\";
? ? ? ? ? ? open.RestoreDirectory = true;
? ? ? ? ? ? open.FilterIndex = 1;
? ? ? ? ? ? open.Filter = "txt文件(*.txt)|*.txt";
? ? ? ? ? ? if (open.ShowDialog() == DialogResult.OK)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? try
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? if (open.OpenFile() != null)
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? txtFileName.Text = open.FileName;
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? catch (Exception err1)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? MessageBox.Show("文件打開錯誤! ?" + err1.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? //發(fā)送文件內容
? ? ? ? private void bntSendFile_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? string fileName = txtFileName.Text.Trim();
? ? ? ? ? ? if (fileName == "")
? ? ? ? ? ? {
? ? ? ? ? ? ? ? MessageBox.Show("請選擇要發(fā)送的文件!", "Error");
? ? ? ? ? ? ? ? return;
? ? ? ? ? ? }
? ? ? ? ? ? else
? ? ? ? ? ? {
? ? ? ? ? ? ? ? //sRead = new StreamReader(fileName);
? ? ? ? ? ? ? ? sRead = new StreamReader(fileName,Encoding.Default);//解決中文亂碼問題
? ? ? ? ? ? }
? ? ? ? ? ? timer1.Start();
? ? ? ? }
? ? ? ? //發(fā)送文件時鐘
? ? ? ? private void timer1_Tick(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? string str1;
? ? ? ? ? ? str1 = sRead.ReadLine();
? ? ? ? ? ? if (str1 == null)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? timer1.Stop();
? ? ? ? ? ? ? ? sRead.Close();
? ? ? ? ? ? ? ? MessageBox.Show("文件發(fā)送成功!", "C#串口通訊");
? ? ? ? ? ? ? ? this.toolStripStatusLabel5.Text = "";
? ? ? ? ? ? ? ? return;
? ? ? ? ? ? }
? ? ? ? ? ? byte[] data = Encoding.Default.GetBytes(str1);
? ? ? ? ? ? sp.Write(data, 0, data.Length);
? ? ? ? ? ? this.toolStripStatusLabel5.Text = " ? 文件發(fā)送中...";
? ? ? ? }
? ? ? ? //接收數(shù)據(jù)
? ? ? ? private void btnReceiveData_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? if (btnReceiveData.Text == "接收數(shù)據(jù)")
? ? ? ? ? ? {
? ? ? ? ? ? ? ? sp.Encoding = Encoding.GetEncoding("GB2312");
? ? ? ? ? ? ? ? if (sp.IsOpen)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? //timer2.Enabled = true; //使用主線程進行

? ? ? ? ? ? ? ? ? ? //使用委托以及多線程進行
? ? ? ? ? ? ? ? ? ? bAccpet = true;
? ? ? ? ? ? ? ? ? ? getRecevice = new Thread(new ThreadStart(testDelegate));
? ? ? ? ? ? ? ? ? ? //getRecevice.IsBackground = true;
? ? ? ? ? ? ? ? ? ? getRecevice.Start();
? ? ? ? ? ? ? ? ? ? btnReceiveData.Text = "停止接收";
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? MessageBox.Show("請先打開串口");
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? else
? ? ? ? ? ? {
? ? ? ? ? ? ? ? //timer2.Enabled = false;
? ? ? ? ? ? ? ? bAccpet = false;
? ? ? ? ? ? ? ? try
? ? ? ? ? ? ? ? { ? //停止主監(jiān)聽線程
? ? ? ? ? ? ? ? ? ? if (null != getRecevice)
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? if (getRecevice.IsAlive)
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? if (!getRecevice.Join(100))
? ? ? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //關閉線程
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? getRecevice.Abort();
? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? getRecevice = null;
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? catch { }
? ? ? ? ? ? ? ? btnReceiveData.Text = "接收數(shù)據(jù)";
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? private void testDelegate()
? ? ? ? {
? ? ? ? ? ? reaction r = new reaction(fun);
? ? ? ? ? ? r();
? ? ? ? }
? ? ? ? //用于接收數(shù)據(jù)的定時時鐘
? ? ? ? private void timer2_Tick(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? string str = sp.ReadExisting();
? ? ? ? ? ? string str2 = str.Replace("\r", "\r\n");
? ? ? ? ? ? txtReceiveData.AppendText(str2);
? ? ? ? ? ? txtReceiveData.ScrollToCaret();
? ? ? ? }
? ? ? ? //下面用到了接收信息的代理功能,此為設計的要點之一
? ? ? ? delegate void DelegateAcceptData();
? ? ? ? void fun()
? ? ? ? {
? ? ? ? ? ? while (bAccpet)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? AcceptData();
? ? ? ? ? ? }
? ? ? ? }

? ? ? ? delegate void reaction();
? ? ? ? void AcceptData()
? ? ? ? {
? ? ? ? ? ? if (txtReceiveData.InvokeRequired)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? try
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? DelegateAcceptData ddd = new DelegateAcceptData(AcceptData);
? ? ? ? ? ? ? ? ? ? this.Invoke(ddd, new object[] { });
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? catch { }
? ? ? ? ? ? }
? ? ? ? ? ? else
? ? ? ? ? ? {
? ? ? ? ? ? ? ? try
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? strRecieve = sp.ReadExisting();
? ? ? ? ? ? ? ? ? ? txtReceiveData.AppendText(strRecieve);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? catch (Exception ex) { }
? ? ? ? ? ? }
? ? ? ? }

? ? ? ? private void bntClear_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? txtReceiveData.Text = "";
? ? ? ? }

? ? ? ? private void button3_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? try
? ? ? ? ? ? {
? ? ? ? ? ? ? ? string path = Directory.GetCurrentDirectory() + @"\output.txt";
? ? ? ? ? ? ? ? string content = this.txtReceiveData.Text;
? ? ? ? ? ? ? ? FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);
? ? ? ? ? ? ? ? StreamWriter write = new StreamWriter(fs);
? ? ? ? ? ? ? ? write.Write(content);
? ? ? ? ? ? ? ? write.Flush();
? ? ? ? ? ? ? ? write.Close();
? ? ? ? ? ? ? ? fs.Close();
? ? ? ? ? ? ? ? MessageBox.Show("接收信息導出在:" + path);
? ? ? ? ? ? }
? ? ? ? ? ? catch (Exception ex)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? MessageBox.Show(ex.Message);
? ? ? ? ? ? }
? ? ? ? }
? ? }
}

效果圖

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

  • unity通過Mesh網(wǎng)格繪制圖形球體

    unity通過Mesh網(wǎng)格繪制圖形球體

    這篇文章主要為大家詳細介紹了unity通過Mesh網(wǎng)格繪制圖形球體,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-11-11
  • WinForm生成驗證碼圖片的方法

    WinForm生成驗證碼圖片的方法

    這篇文章主要介紹了WinForm生成驗證碼圖片的方法,涉及WinForm字符串及圖形操作的相關技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2016-06-06
  • C#實現(xiàn)將PDF轉為線性化PDF

    C#實現(xiàn)將PDF轉為線性化PDF

    線性化PDF文件是PDF文件的一種特殊格式,可以通過Internet更快地進行查看。這篇文章主要介紹了如何通過C#實現(xiàn)將PDF轉為線性化PDF,感興趣的小伙伴可以學習一下
    2021-12-12
  • C#獲取HTML文本的第一張圖片與截取內容摘要示例代碼

    C#獲取HTML文本的第一張圖片與截取內容摘要示例代碼

    在日常web開發(fā)的時候,經常會遇到需要獲取保存的HTML文本中的第一張圖片,并且截取內容摘要的效果,例如織夢的后臺添加完詳細內容后就是自動讀取內容摘要,并保存第一張圖片為縮略圖,那么這篇文章跟大家分享下利用C#如何實現(xiàn),感興趣的朋友們下面來一起看看吧。
    2016-10-10
  • C#內置隊列類Queue用法實例

    C#內置隊列類Queue用法實例

    這篇文章主要介紹了C#內置隊列類Queue用法,實例分析了C#內置隊列的添加、移除等相關技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-04-04
  • C#中DataSet,DataTable,DataView的區(qū)別與用法

    C#中DataSet,DataTable,DataView的區(qū)別與用法

    這篇文章介紹了C#中DataSet,DataTable,DataView的區(qū)別與用法,文中通過示例代碼介紹的非常詳細。對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-05-05
  • 基于C#實現(xiàn)在圖片上繪制文字

    基于C#實現(xiàn)在圖片上繪制文字

    這篇文章主要為大家詳細介紹了如何利用C#實現(xiàn)在圖片上繪制文字的效果,文中的示例代碼講解詳細,對我們學習C#有一定的幫助,感興趣的小伙伴可以跟隨小編一起了解一下
    2022-12-12
  • C#強制類型轉換小結

    C#強制類型轉換小結

    任何一門編程語言均有相關數(shù)據(jù)類型。C#也不例外,不過轉換過程要注意小類型能轉換成大類型,但大類型一般不能轉換成小類型,下面小編給大家詳解C#強制類型轉換小結,需要的朋友參考下吧
    2017-07-07
  • C#實現(xiàn)輸入10個數(shù)存入到數(shù)組中并求max和min及平均數(shù)的方法示例

    C#實現(xiàn)輸入10個數(shù)存入到數(shù)組中并求max和min及平均數(shù)的方法示例

    這篇文章主要介紹了C#實現(xiàn)輸入10個數(shù)存入到數(shù)組中并求max和min及平均數(shù)的方法,涉及C#簡單數(shù)據(jù)轉換與數(shù)值運算相關操作技巧,需要的朋友可以參考下
    2017-07-07
  • C#異步使用需要注意的幾個問題

    C#異步使用需要注意的幾個問題

    C#使用異步方法中,使用一下關鍵詞的時候徐注意一些問題,比如async 方法需在其主體中具有 await 關鍵字,否則它們將永不暫停,接下來文字里將為大家舉例說明
    2021-09-09

最新評論