zoukankan
html css js c++ java
按不同国家语言进行字符串排序
void
Page_Load(
object
sender, EventArgs e)
{
//
测试数据
string
[] myArr
=
new
string
[
6
];
myArr[
0
]
=
"
地域
"
;
myArr[
1
]
=
"
地図
"
;
myArr[
2
]
=
"
路線
"
;
myArr[
3
]
=
"
道路交通
"
;
myArr[
4
]
=
"
電話帳
"
;
myArr[
5
]
=
"
自動車
"
;
//
没有排序
Gridview1.DataSource
=
myArr;
Gridview1.DataBind();
//
简体中文排序
MyStringComparer myComp
=
new
MyStringComparer(CompareInfo.GetCompareInfo(
"
zh-CN
"
), CompareOptions.None);
Array.Sort(myArr, myComp);
Gridview2.DataSource
=
myArr;
Gridview2.DataBind();
//
日语排序
myComp
=
new
MyStringComparer(CompareInfo.GetCompareInfo(
"
ja-JP
"
), CompareOptions.None);
Array.Sort(myArr, myComp);
Gridview3.DataSource
=
myArr;
Gridview3.DataBind();
}
private
class
MyStringComparer : IComparer
{
private
CompareInfo myComp;
private
CompareOptions myOptions
=
CompareOptions.None;
//
Constructs a comparer using the specified CompareOptions.
public
MyStringComparer(CompareInfo cmpi, CompareOptions options)
{
myComp
=
cmpi;
this
.myOptions
=
options;
}
//
Compares strings with the CompareOptions specified in the constructor.
public
int
Compare(Object a, Object b)
{
if
(a
==
b)
return
0
;
if
(a
==
null
)
return
-
1
;
if
(b
==
null
)
return
1
;
string
sa
=
a.ToString();
string
sb
=
b.ToString();
if
(sa
!=
null
&&
sb
!=
null
)
return
myComp.Compare(sa, sb, myOptions);
throw
new
ArgumentException(
"
a and b should be strings.
"
);
}
}
查看全文
相关阅读:
wordpress 自己制作子主题 child theme
wordpress 主题开发
python的曲线平滑工具,及python画一条线中包含不同粗细不同颜色的画线方法
openfire 使用已有的数据库作为用户认证数据库 Custom Database Integration Guide
How to store scaling parameters for later use
在android上跑 keras 或 tensorflow 模型
Win10更新搜狗输入法后重启输入密码蓝屏
Audition CC2019 MME设备内部错误怎么解决!
数据库优化解决方案
微信小程序文本如何换行
原文地址:https://www.cnblogs.com/goodspeed/p/62715.html
最新文章
iOS: 如何调节UITabbarItem的图片和文字位置
iOS: 向Github的README.md里添加图片
iOS:使用Github托管自己本地的项目代码方式一:(Xcode方式:开发工具Xcode配置Git,由Xcode-->Source Control-->Commit)
iOS:使用贝塞尔曲线绘制图表(折线图、柱状图、饼状图)
iOS: 如何获取ios设备的当前IP地址
iOS: iOS各种设备信息获取
AE二次开发技巧之撤销、重做
ArcGIS Engine 中 Geometric Network 显示流向代码
ArcGis 中MapControl 框选
TIF、JPG图片手动添加地理坐标的方法(转载)
热门文章
ArcGis 计算线段长度
C# 使用正则表达式去掉字符串中的数字,或者去掉字符串中的非数字
ArcGis 创建IWorkspace
ArcGis 获取地理、平面坐标系
The Geometry has no Z values 解决办法
【ArcGIS二次开发】CreateFeature报错(HRESULT E_FAIL)
Android Studio下编译调试 ndk 的示例
图像增强的库 neural-enhance
文字识别的google的库 tesseract
如何通过 ClickBank 等类似虚拟平台进行在线销售并获得收益
Copyright © 2011-2022 走看看