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; } } } }