当前位置:网站首页>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!");
}
}
}
边栏推荐
- 剑指Offer07. 重建二叉树
- 最新版盲盒商城thinkphp+uniapp
- [ArcGIS user defined script tool] vector file generates expanded rectangular face elements
- 基于Linu开发的项目视频
- Deeply understand the mvcc mechanism of MySQL
- 【计网】第三章 数据链路层(2)流量控制与可靠传输、停止等待协议、后退N帧协议(GBN)、选择重传协议(SR)
- Integer case study of packaging
- Xctf mobile--app1 problem solving
- Take you to the installation and simple use tutorial of the deveco studio compiler of harmonyos to create and run Hello world?
- [Exercice 5] [principe de la base de données]
猜你喜欢

Social community forum app ultra-high appearance UI interface

剑指Offer07. 重建二叉树

initial、inherit、unset、revert和all的区别

Xctf mobile--rememberother problem solving
![[comprehensive question] [Database Principle]](/img/d7/8c51306bb390e0383a017d9097e1e5.png)
[comprehensive question] [Database Principle]

Sword finger offer14 the easiest way to cut rope

【R】【密度聚类、层次聚类、期望最大化聚类】

Ali & ant self developed IDE
![[ArcGIS user defined script tool] vector file generates expanded rectangular face elements](/img/39/0b31290798077cb8c355fbd058e4d3.png)
[ArcGIS user defined script tool] vector file generates expanded rectangular face elements

公纵号发送提示信息(用户微服务--消息微服务)
随机推荐
并网-低电压穿越与孤岛并存分析
初入职场,如何快速脱颖而出?
Sword finger offer10- I. Fibonacci sequence
[problem exploration and solution of one or more filters or listeners failing to start]
Pytext training times error: typeerror:__ init__ () got an unexpected keyword argument 'serialized_ options'
Tensorflow binary installation & Failure
Sqoop1.4.4原生增量导入特性探秘
如何在微信小程序中获取用户位置?
Nodejs+express+mysql realizes login function (including verification code)
Ali & ant self developed IDE
Social community forum app ultra-high appearance UI interface
【综合题】【数据库原理】
Ten workplace rules
01 three solutions to knapsack problem (greedy dynamic programming branch gauge)
Sword finger offer04 Search in two-dimensional array [medium]
Dix règles de travail
【数据库原理及应用教程(第4版|微课版)陈志泊】【第七章习题】
Differences between initial, inherit, unset, revert and all
剑指Offer09. 用两个栈实现队列
Everything comes to him who waits