winform 如何实现字典的速录

wxz2410 2010-11-22 10:11:13
数据库中存在字典行数据,在窗体上输入部分拼音就能出现字典中包括这些拼音的汉字,例如 字典中有“河西区大沽南路”“河东区区政府”,在输入“hd”时就会出现“河东区区政府”,用代码如何实现?
...全文
79 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
peterb 2010-11-22
  • 打赏
  • 举报
回复
搜索汉字转拼音
garfieldzf 2010-11-22
  • 打赏
  • 举报
回复


/// <summary>
/// 返回汉字字符串的拼音的首字母
/// </summary>
/// <param name="chinesestr">要转换的字符串</param>
/// <returns></returns>
public static string Chinesecap(string chinesestr)
{
byte[] zw = new byte[2];
long chinesestr_int;
string charstr, chinastr = null, capstr = null;
for (int i = 0; i <= chinesestr.Length - 1; i++)
{
charstr = chinesestr.Substring(i, 1).ToString();
if (charstr == " ")
{
continue;
}
zw = System.Text.Encoding.Default.GetBytes(charstr);
// 得到汉字符的字节数组
if (zw.Length == 2)
{
int i1 = (short)(zw[0]);
int i2 = (short)(zw[1]);
chinesestr_int = i1 * 256 + i2;
//table of the constant list
// a; //45217..45252
// b; //45253..45760
// c; //45761..46317
// d; //46318..46825
// e; //46826..47009
// f; //47010..47296
// g; //47297..47613

// h; //47614..48118
// j; //48119..49061
// k; //49062..49323
// l; //49324..49895
// m; //49896..50370
// n; //50371..50613
// o; //50614..50621
// p; //50622..50905
// q; //50906..51386

// r; //51387..51445
// s; //51446..52217
// t; //52218..52697
//没有u,v
// w; //52698..52979
// x; //52980..53640
// y; //53689..54480
// z; //54481..55289

if ((chinesestr_int >= 45217) && (chinesestr_int <= 45252))
{
chinastr = "a";
}
else if ((chinesestr_int >= 45253) && (chinesestr_int <= 45760))
{
chinastr = "b";
}
else if ((chinesestr_int >= 45761) && (chinesestr_int <= 46317))
{
chinastr = "c";
}
else if ((chinesestr_int >= 46318) && (chinesestr_int <= 46825))
{
chinastr = "d";
}
else if ((chinesestr_int >= 46826) && (chinesestr_int <= 47009))
{
chinastr = "e";
}
else if ((chinesestr_int >= 47010) && (chinesestr_int <= 47296))
{
chinastr = "f";
}
else if ((chinesestr_int >= 47297) && (chinesestr_int <= 47613))
{
chinastr = "g";
}
else if ((chinesestr_int >= 47614) && (chinesestr_int <= 48118))
{
chinastr = "h";
}
else if ((chinesestr_int >= 48119) && (chinesestr_int <= 49061))
{
chinastr = "j";
}
else if ((chinesestr_int >= 49062) && (chinesestr_int <= 49323))
{
chinastr = "k";
}
else if ((chinesestr_int >= 49324) && (chinesestr_int <= 49895))
{
chinastr = "l";
}
else if ((chinesestr_int >= 49896) && (chinesestr_int <= 50370))
{
chinastr = "m";
}
else if ((chinesestr_int >= 50371) && (chinesestr_int <= 50613))
{
chinastr = "n";
}
else if ((chinesestr_int >= 50614) && (chinesestr_int <= 50621))
{
chinastr = "o";
}
else if ((chinesestr_int >= 50622) && (chinesestr_int <= 50905))
{
chinastr = "p";
}
else if ((chinesestr_int >= 50906) && (chinesestr_int <= 51386))
{
chinastr = "q";
}
else if ((chinesestr_int >= 51387) && (chinesestr_int <= 51445))
{
chinastr = "r";
}
else if ((chinesestr_int >= 51446) && (chinesestr_int <= 52217))
{
chinastr = "s";
}
else if ((chinesestr_int >= 52218) && (chinesestr_int <= 52697))
{
chinastr = "t";
}
else if ((chinesestr_int >= 52698) && (chinesestr_int <= 52979))
{
chinastr = "w";
}
else if ((chinesestr_int >= 52980) && (chinesestr_int <= 53640))
{
chinastr = "x";
}
else if ((chinesestr_int >= 53689) && (chinesestr_int <= 54480))
{
chinastr = "y";
}
else if ((chinesestr_int >= 54481) && (chinesestr_int <= 55289))
{
chinastr = "z";
}
}
else
{
capstr = chinesestr;
break;
}

capstr = capstr + chinastr;
}
return capstr;
}
内容概要:本文围绕城市场景下无人机三维路径规划中的导航变量多目标优化问题,提出了一种改进的多目标粒子群优化算法(NMOPSO),旨在应对高维、多约束条件下路径规划的复杂性。研究在Matlab平台上实现了算法仿真,通过构建精细化的城市三维环境模型,综合考虑路径长度、飞行安全性、能耗等多个优化目标,有效提升了无人机在复杂城市环境中执行任务时的路径规划效率与可靠性。文中系统阐述了NMOPSO算法的设计原理、实现流程及关键参数配置,并通过大量对比实验验证了该算法在收敛速度、解集多样性和Pareto前沿质量方面相较于传统多目标优化算法的显著优势; 适合人群:具备一定优化算法理论基础和Matlab编程能力的研究生、科研人员及从事无人机路径规划、智能优化算法研发的工程技术人员; 使用场景及目标:①应用于城市环境下的无人机物流配送、电力巡检、应急救援等实际任务中的高效路径规划;②为高维多目标优化问题的研究与先进智能算法的改进提供高质量的参考案例,推动智能优化技术在无人系统自主决策领域的深入应用; 阅读建议:建议读者结合提供的Matlab代码进行动手实践,重点研读目标函数的数学建模、环境约束的处理机制以及算法性能评价指标的设计,以深入理解NMOPSO算法的核心创新点与工程实现细节。

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧