C 常用方法

2021-06-10 06:57:59 字數 386 閱讀 5178

當字串連線很長的適合用stringbuilder效能會好一點。

判斷是否是數值的方法:

int output=0;

bool isnumeric=int.tryparse(value,out output);

int.tryparse是更快、更簡潔的方法,而不是用try catch來判斷。

convert.tosingle

將指定的 

decimal

的值轉換為等效的單精度浮點數字。

通俗一點:可以把double型別的值轉換成最小精度的double值。比如100.005,處理之後還是100.005,但100.00500處理之後就是100.00500,這個應用在**上很受用。

C 常用方法

1 datetime 數字型 system.datetime currenttime new system.datetime 1.1 取當前年月日時分秒 currenttime system.datetime.now 1.2 取當前年 int 年 currenttime.year 1.3 取當前月 ...

c 常用方法

驗證是否超過索引 索引值 返回值 private string getstringbyindex int i,string strs return res 方法說明 將原始字串間加入換行符 需要分割的字串 已分割的字串 public string splitstring string oristri...

常用排序方法(C

public class sortalgorithm 插入排序 param numlist private void insertsort intnumlist numlist in temp 選擇排序 private void selectionsort intnumlist system.out...