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.
"
);
}
}
查看全文
相关阅读:
在线加密解密
ctcms Nginx 伪静态
iTem2 保持连接,解决ssh的"Write failed: Broken pipe"问题
打开窗口弹出页面
点击弹窗
javascript 技巧
使用Chrome工具来分析页面的绘制状态
jquery结合JSONP教程—明河谈jquery
使用 JSONP 实现跨域通信,第 1 部分: 结合 JSONP 和 jQuery 快速构建强大的 mashup
jsonp详解
原文地址:https://www.cnblogs.com/goodspeed/p/62715.html
最新文章
【转】关联、组合、聚合、依赖关系比较
Sokcet方式请求HTTP/HTTPS的封装类HttpHelper
网页游戏外挂辅助AMF模拟通讯必备
【原创】cs+html+js+css模式(七): 顺序执行与并发执行问题,IIS7及其以上版本的抛错问题解决
【原创】cs+html+js+css模式(六):改造ajax.js,从原来的原生态js修改为依赖于jquery插件
根据多年经验整理的《互联网MySQL开发规范》
PHP程序员的技术成长规划
psd切图
Linux高级权限管理
sed
热门文章
TCP/IP知识点汇总
linux 知识汇总
centos BIND服务基础及域主服务器配置
Linux系统信息查看
vi/vim基本使用方法
尼尔森的十大可用性原则
CSS实现跨浏览器兼容性的盒阴影效果
字体网站收集
有意思的域名Hack网站
宝塔面板nginx配置安装Discuz
Copyright © 2011-2022 走看看