当前位置:网站首页>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!");
}
}
}
边栏推荐
- [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)
- 社交社区论坛APP超高颜值UI界面
- 剑指Offer10- I. 斐波那契数列
- [problem exploration and solution of one or more filters or listeners failing to start]
- Enter the length of three sides of the triangle through the user, and calculate the area of the triangle, where the length is a real number
- Sword finger offer09 Implementing queues with two stacks
- 【数据库原理复习题】
- 并网-低电压穿越与孤岛并存分析
- (latest version) WiFi distribution multi format + installation framework
- 十條職場規則
猜你喜欢

Method overloading and rewriting

【数据挖掘复习题】

Four problems and isolation level of MySQL concurrency

阿里大于发送短信(用户微服务--消息微服务)

Take you to the installation and simple use tutorial of the deveco studio compiler of harmonyos to create and run Hello world?

阿里 & 蚂蚁自研 IDE

GaN图腾柱无桥 Boost PFC(单相)七-PFC占空比前馈

Seven second order ladrc-pll structure design of active disturbance rejection controller

Leetcode234 palindrome linked list

【ArcGIS自定义脚本工具】矢量文件生成扩大矩形面要素
随机推荐
node的ORM使用-Sequelize
Project video based on Linu development
最新版抽奖盲盒运营版
Sword finger offer07 Rebuild binary tree
剑指Offer03. 数组中重复的数字【简单】
OpenStack节点地址改变
Deeply understand the mvcc mechanism of MySQL
剑指Offer05. 替换空格
Xctf mobile--app3 problem solving
Swift bit operation exercise
Social community forum app ultra-high appearance UI interface
双链笔记·思源笔记综合评测:优点、缺点、评价
Quickly learn member inner classes and local inner classes
[combinatorics] permutation and combination (multiple set permutation | multiple set full permutation | multiple set incomplete permutation all elements have a repetition greater than the permutation
4. Wireless in vivo nano network: electromagnetic propagation model and key points of sensor deployment
TOGAF认证自学宝典V2.0
The best shortcut is no shortcut
I'm too lazy to write more than one character
Using swift language features, write a pseudo-random number generator casually
【习题五】【数据库原理】