1樓:小小木歌
小小案例提示(自己參照):
public static bool yanzheng(string str)
catch
return true;
}static void main(string args),能被轉換成int型別",str);
}else}
2樓:
輸入的都是字串
只能根據自己的需要轉換成對應的型別
可以使用convert類來進行轉換,並通過捕獲異常還判斷輸入是否正確
3樓:匿名使用者
1.public bool textvalueisint(object obj)
catch()
return boolflag;}2
使用正則:
////// 檢測是否整數型資料
////// 待檢查資料
///public static bool isinteger(string input)
else
}///
/// 是否全是正整數
/////////public static bool isinteger(string input, bool plus)
else
else}}
////// 判斷輸入是否為日期型別
////// 待檢查資料
///public static bool isdate(string s)
catch}
4樓:
可以用最強大的正則驗證啊!如下面驗證輸入的使用者名稱和密碼:
regex rx = new regex("(^[\u4e00-\u9fa5]$)|(^[a-za-z0-9]$)|(^[\u4e00-\u9fa5a-za-z0-9]$)");
match ma1 = rx.match(strusername);
match ma2 = rx.match(strpassword);
bool bo1 = ma1.success;
bool bo2 = ma2.success;
if (bo1 == true && bo2 == true)else
5樓:
哪用得著那麼麻煩,
console.writeline("變數名".gettype().tostring());
輸入的就是當前變數的型別
6樓:小貴哥
**判斷,isnumberable(string)
7樓:劉青峰
字串就是字串型別啊,還能是什麼型別。輸入的都是字串型別。。。。
c#程式設計編寫一個控制檯應用程式對使用者輸入的單個字元進行判斷,判別該字元為大寫,小寫,其他字元;
8樓:匿名使用者
類似判斷
if (convert.toint32('a') >= 65 && convert.toint32('a') <=90)
大寫字母編碼範圍內65-90、小寫字母範圍97-122其他字元 等,判斷容一下字元編碼是否在這個範圍內 就可以確定屬於哪一類了
c#如何在控制檯程式中輸入字元?
9樓:習慣了孤寂心
示例**:
class program
console.readkey(true);
}static void test()
else}}
10樓:匿名使用者
class program
console.readkey(true);
}static void test()
else}}
11樓:匿名使用者
while (true)}
12樓:匿名使用者
bool bisnumber = false;
int d;
char ch;
int i = console.read();//讀取一來個源文字
baich = convert.tochar(i);
bisnumber= int32.tryparse(ch.tostring(), d);
//判斷是du
否為zhi數dao字
13樓:劍劍
try}
catch(expetion ex)
C控制台程式怎麼實現迴圈執行
我有乙個簡單的辦法 goto法 在你的想要重新執行的 前加上標籤。如 start 你的程式 console.writeline 是否再次執行程式?是就按 1 否就按 2 關閉程式 byte i convert.tobyte console.readline if i 1 使用if語句判斷條件,滿足就...
用c控制台應用程式,對輸入的整數,求出其中的最大數和最小數,並輸出。求解謝謝
彭季雅 氣泡排序 bubblesort 的基本概念是 依次比較相鄰的兩個數,將小數放在前面,大數放在後面。即在第一趟 首先比較第1個和第2個數,將小數放前,大數放後。然後比較第2個數和第3個數,將小數放前,大數放後,如此繼續,直至比較最後兩個數,將小數放前,大數放後。至此第一趟結束,將最大的數放到了...
設計C 控制台應用程式,執行時,輸入兩個正整數,計算並輸出這兩個數之間所有不能被3和7整除的數的和
include using namespace std void main 至此,number1必然小於number2for temp number1 1 temp number2 1 temp temp逐個取number1和number2之間的數 cout cout 結果是 include usi...