而且上課還要邊練習時間有點不足
就隨筆記錄一些Google過的問題吧OuO
判斷字串是否可以轉換成數字
int n;//double, float寫法同
bool isNumeric = int.TryParse("123", out n);//"123"可換字串
參考:How do I identify if a string is a number?List使用
//宣告
List<int> myLists = new List<int>();
//取得List長度(內容總數)
myLists.Count;
//搜尋 + 刪除
bool isFind = false;
int count = 0;
foreach (String i in myLists)
{
if (i == 99)
{
isFind = true;
myLists.RemoveAt(count);
break;
}
count++;
}
參考:C# 裡 List用法,有點像是不用宣告長度的陣列(Array)收集(Collections of Label, TextBox, Button)
List<control> collections = new List<control>();
//使用 collections.Add(); 收集到List裡
//應用:全部設定屬性
foreach (Control i in collections)
{
i.Visible = true;
}
參考:Control 類別把List加進List裡
//利用 .AddRange()參考:How to add List<> to a List<> in asp.net [duplicate]

沒有留言:
張貼留言