C#基础

check获取方法

 

int Result = 0;
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++) //循环datagridview每行
{
if ((bool)dataGridView1.Rows[i].Cells[27].EditedFormattedValue == true)
{
Result += 1;
}
}

一次获取多行 Rows[x]在循环里面使用

 

    string FID = this.dataGridView1.Rows[x].Cells["FID"].Value.ToString();

 

split如何在截取字符串时只截取最后一个符号

string arr = TestURl.Split('\\')[TestURl.Split('\\').Length - 1]; 

SunnyUI 是一种开源免费的软件 NuGet开发包添加一下就可以了

局部变量 可以全局调用 但是数据不能自动清除  要自己声明清楚

截取字符串

 double b = Convert.ToDouble(a.Substring(0, a.Length - 1));

 

if(data.Rows[0]["A"] == DBNull.Value) 判断int是否等于空 不会报错

string str = serialPort1.ReadExisting();//字符串方式读

string number = string.Join("", str.Split(' '));//去空格

string lin = number.Substring(6, 8);//截取数据    开始字符   接收字符

 

string[] Aaay = new string[37]; //截取字符串 +=0027.B

str = serialPort1.ReadExisting();//字符串方式读

 Aaay = str.Split('=');

for (i = 0; i < Aaay.Length; i++)
{
if (Aaay.Length > 2)
{
if (Aaay[i] != null)
{
String[] Aaay2 = Aaay[i].Split('.');

}

}

浮点型转两位数的方法

double a = 2.321321321;
string result = a.ToString("#0.0");

 

List集合可以存放List集合 调用AddRange()方法就可以List添加数据 Add()只要类型相同就可以添加进去

 

异步时想把数据写入控件必须写

 

 写入方法体里面

 

posted @ 2021-09-19 16:21  林新i  阅读(231)  评论(0编辑  收藏  举报