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

C#如何將List<string>轉(zhuǎn)換為L(zhǎng)ist<double>

 更新時(shí)間:2023年07月11日 15:24:36   作者:書(shū)香玫瑰  
這篇文章主要介紹了C#如何將List<string>轉(zhuǎn)換為L(zhǎng)ist<double>問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

C#將List<string>轉(zhuǎn)換為L(zhǎng)ist<double>

//string轉(zhuǎn)List<double>
List<string> strList = new List<string>();
strList.Add("100"); strList.Add("500"); strList.Add("700");
List<double> douList = strList.ConvertAll(s => Convert.ToDouble(s));
string str = "600 650 700";
List<double> douList2 = str.Split(' ').ToList().ConvertAll(s => Convert.ToDouble(s));
//List<double>轉(zhuǎn)string
string douStr = string.Join(" ", douList2.ConvertAll(s => Convert.ToString(s)));//douStr : 600 650 700

C#基礎(chǔ)知識(shí)點(diǎn)匯總之string與double相互轉(zhuǎn)換

string 轉(zhuǎn) double

string 類(lèi)型的 數(shù)字字符串,如"3.14",轉(zhuǎn)換為數(shù)值:3.14

double num = Convert.ToDouble("3.14");
double total_battery_capacity = Convert.ToDouble(this.txtbox_battery_totoal_capacity.Text);

double 轉(zhuǎn) string

double 是數(shù)值,如3.14,轉(zhuǎn)換為:“3.14”

string str_num = Convert.ToString(3.14);
string str_battery_actual_capacity = Convert.ToString(total_battery_capacity * battery_ratio);

獲取文本框的值

C# 文本框的值為:string

string str_name = this.txtbox_battery_ratio.Text;

注意這里的Text 沒(méi)有括號(hào)

文本框更新值

如把 “hello world” 設(shè)置到文本框

this.txtbox_hello.Text = "hello world";
this.txtbox_run_power.Text = Convert.ToString(run_power);

更改文本框字體顏色

this.txtbox_life_days.ForeColor = Color.Red;
this.txtbox_run_average_power.ForeColor = Color.Blue;

心得

可以使用C#快速做小工具,應(yīng)用開(kāi)發(fā)很簡(jiǎn)單

界面可以做的很美觀,功能強(qiáng)大

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論