C# 入门经典示例.
?
??? class Class3
??? {
?????? static int a = ushort.MaxValue, b;
?????? static short c;
??????? static void Main()
??????? {
????????? //調試的時候不會報錯。
????????????
??????????????? Console.WriteLine(a);
??????????????? c = (short)a;
?
??????????????? Console.WriteLine(c);
?? ? ? ?}
??? }
?
?
??? class Class3
??? {
?????? static int a = ushort.MaxValue, b;
?????? static short c;
??????? static void Main()
??????? {
?
?? ? ? ? ? ?Checked ?//調試的時候如果出現溢出,會報錯。直接運行不會報錯。??????????? {
??????????????? Console.WriteLine(a);
??????????????? c = (short)a;
?
??????????????? Console.WriteLine(c);
??????????? }
?? ?
??????? }
??? }
?
??? class Class3
??? {
?????? static int a = ushort.MaxValue, b;
?????? static short c;
??????? static void Main()
??????? {
?
?
??????????? int a;
??????????? string ok = Console.ReadLine();
??????????? Console.WriteLine(int.TryParse(ok, out a));
??????????? Console.WriteLine(a);
?
??????????? string temp = Console.ReadLine();
??????????? char[] ok = new char[] { ' ', '1' };
??????????? string[] tempArray = temp.Split(ok);
??????????? foreach (var item in tempArray)
??????????? {
??????????????? Console.WriteLine(item);
?
??????????? }
??????????? Console.WriteLine("順3序¨°相¨¤反¤??輸o?出?");
??????????? string Lstring = Console.ReadLine();
??????????? for (int i = Lstring.Length - 1; i >= 0; i--)
??????????? {
??????????????? Console.WriteLine(Lstring[i]);
?
??????????? }
?
??????????? Console.WriteLine("把??Yes 替??換?為a No");
?
??????????? string LString = Console.ReadLine();
??????????? LString = LString.Replace("yes", "No");
??????????? Console.WriteLine(LString);
?
???????????
???????????
??????????? Console.WriteLine("給?每?個?單죤詞?¨o加¨?上|?雙?引°y號?");
????????
??????????? string Lstring = Console.ReadLine();
??????????? string[] Rstring = Lstring.Split(' ');
??????????? string result = null;
??????????? foreach (var item in Rstring)
??????????? {
??????????????? if (item == string.Empty)
??????????????????? continue;
??????????????? result += "\"" + item + "\"";
?
??????????? }
?
???
?
??????????? Console.WriteLine(result);
?
?
?
?
??????????
???????????
???????????
?
??
???????????
??????? }
??? }
?
?
轉載于:https://www.cnblogs.com/fat_li/archive/2011/01/29/1947444.html
總結
以上是生活随笔為你收集整理的C# 入门经典示例.的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android 机顶盒手势、数据分页演示
- 下一篇: navicat提权