当前位置:网站首页>C graphical tutorial (Fourth Edition)_ Chapter 15 interface: interfacesamplep271
C graphical tutorial (Fourth Edition)_ Chapter 15 interface: interfacesamplep271
2022-07-03 12:52:00 【superfreak】
using System;
namespace Chapter15InterfaceSampleP271
{
class MyClass :IComparable// Class implementation reference
{
public int TheValue;
public int CompareTo(object obj)// Implementation method
{
MyClass mc=(MyClass)obj;
if (this.TheValue<mc.TheValue) return -1;
if (this.TheValue > mc.TheValue) return 1;
return 0;
}
}
class Program
{
static void PrintOut(string s, MyClass[] mc)
{
Console.Write(s);
foreach (var m in mc)
{
Console.Write("{0}、", m.TheValue);
}
Console.WriteLine("");
}
static void Main(string[] args)
{
var myInt = new[] { 20,4,16,9,2};
MyClass[] mcArr = new MyClass[5];
for (int i = 0; i < 5; i++)
{
mcArr[i] = new MyClass();
mcArr[i].TheValue = myInt[i];
}
PrintOut("Initial Order:",mcArr);
Array.Sort(mcArr);
PrintOut("Sorted Order:", mcArr);
Console.WriteLine("Hello World!");
}
}
}
边栏推荐
猜你喜欢
Huffman coding experiment report
阿里 & 蚂蚁自研 IDE
How to convert a decimal number to binary in swift
4. Wireless in vivo nano network: electromagnetic propagation model and key points of sensor deployment
剑指Offer09. 用两个栈实现队列
GaN图腾柱无桥 Boost PFC(单相)七-PFC占空比前馈
低代码平台国际化多语言(i18n)技术方案
Leetcode234 palindrome linked list
The latest version of blind box mall thinkphp+uniapp
[ArcGIS user defined script tool] vector file generates expanded rectangular face elements
随机推荐
Nodejs+Express+MySQL实现登陆功能(含验证码)
双链笔记·思源笔记综合评测:优点、缺点、评价
Export the entire Oracle Database
[network counting] Chapter 3 data link layer (2) flow control and reliable transmission, stop waiting protocol, backward n frame protocol (GBN), selective retransmission protocol (SR)
Redhat5 installing socket5 proxy server
【数据挖掘复习题】
Tensorflow binary installation & Failure
Openstack node address change
How to get user location in wechat applet?
Glide question you cannot start a load for a destroyed activity
How to stand out quickly when you are new to the workplace?
公纵号发送提示信息(用户微服务--消息微服务)
记录自己vulnhub闯关记录
Node.js: express + MySQL的使用
Sword finger offer05 Replace spaces
T430 toss and install OS majave 10.14
Oh my Zsh + TMUX installation
低代码平台国际化多语言(i18n)技术方案
Togaf certification self-study classic v2.0
十條職場規則