首页 c#课堂实验代码2

c#课堂实验代码2

举报
开通vip

c#课堂实验代码24、编写一个类,其中包含一个排序的方法Sort(),当传入的是一串整数,就按照从小到大的顺序输出, 如果传入的是一个字符串,就将字符串反序输出。 class Program { static void Main(string[] args) { Console.WriteLine("请输入字符串"); string str = Console.ReadLine(); orderby.sort(str); } } class orderby { public static void sort(string str) ...

c#课堂实验代码2
4、编写一个类,其中包含一个排序的 方法 快递客服问题件处理详细方法山木方法pdf计算方法pdf华与华方法下载八字理论方法下载 Sort(),当传入的是一串整数,就按照从小到大的顺序输出, 如果传入的是一个字符串,就将字符串反序输出。 class Program { static void Main(string[] args) { Console.WriteLine("请输入字符串"); string str = Console.ReadLine(); orderby.sort(str); } } class orderby { public static void sort(string str) { if ((int)str[0] >= 48 && (int)str[0] <= 57) { char[] num = str.ToCharArray(); for (int i = 1; i < num.Length; i++) { for (int j = 0; j < num.Length - i; j++) { if (num[j] > num[j + 1]) { char temp = num[j]; num[j] = num[j + 1]; num[j + 1] = temp; } } foreach (char a in str) { Console.Write(a); } } } else { for (int i = str.Length-1; i >=0; i--) { Console.Write(str[i]); } } 5、 设计 领导形象设计圆作业设计ao工艺污水处理厂设计附属工程施工组织设计清扫机器人结构设计 一个类,要求用事件每10秒报告机器的当前时间。 public class TimeMonitor { private bool Stop = false; private System.Threading.Thread MonitorThread = null; public void StartMonitor() { MonitorThread = new Thread(new ThreadStart(Monitor)); MonitorThread.Start(); } public void Monitor(){ while(!Stop) { System.Windows.Forms.MessageBox.Show(System.DateTime.Now.ToString()); System.Threading.Sleep(10000); } } public void StopMonitor(); { Stop = true; MonitorThread.Abort(); } } 6、编写一个类,要求带有一个索引器可以存储100个整型变量。 using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { int[] intX = new int[100]; public int this[int index] { get { if (index < 0 || index > intX.Length) throw new Exception("超出索引!"); return this.intX[index]; } set { if (index < 0 || index > intX.Length) throw new Exception("超出索引!"); this.intX[index] = value; } } } }
本文档为【c#课堂实验代码2】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_377716
暂无简介~
格式:doc
大小:27KB
软件:Word
页数:3
分类:互联网
上传时间:2011-07-14
浏览量:40