热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

汉字求出拼音缩写

usingSystem;namespaceCsharpPinYing{**PinYinClass的摘要说明。publicclassPinYinClass{publicPinYinC

 

None.gifusing System;
None.gif
None.gif
namespace CsharpPinYing 
ExpandedBlockStart.gifContractedBlock.gif
dot.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif 
/**//// 
InBlock.gif 
/// PinYinClass 的摘要说明。 
ExpandedSubBlockEnd.gif 
/// 

InBlock.gif public class PinYinClass 
ExpandedSubBlockStart.gifContractedSubBlock.gif 
dot.gif
InBlock.gif  
public PinYinClass() 
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif
InBlock.gif   
// 
InBlock.gif   
// TODO: 在此处添加构造函数逻辑 
InBlock.gif   
// 
ExpandedSubBlockEnd.gif
  }
 
InBlock.gif  
private String PinYin(String mystr) 
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif
InBlock.gif   String tt; 
InBlock.gif   
if ((mystr.ToUpper().CompareTo("A")>=0 && 
InBlock.gifmystr.ToUpper().CompareTo(
"Z")<&#61;0)|| (mystr.ToUpper().CompareTo("0")>&#61;0 && 
InBlock.gifmystr.ToUpper().CompareTo(
"9")<&#61;0)) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;mystr; 
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
else if (Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;"1"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
else if (Asc(mystr) >&#61; Asc(""&& Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;"a"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
else if (Asc(mystr) >&#61; Asc(""&& Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;"b"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
else if (Asc(mystr) >&#61; Asc(""&& Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;"c"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
else if (Asc(mystr) >&#61; Asc(""&& Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;"d"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
else if (Asc(mystr) >&#61; Asc(""&& Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;"e"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
else if (Asc(mystr) >&#61; Asc(""&& Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;"f"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
else if (Asc(mystr) >&#61; Asc(""&& Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;"g"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
else if (Asc(mystr) >&#61; Asc(""&& Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif 
dot.gif
InBlock.gif    tt
&#61;"h"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
else if (Asc(mystr) >&#61; Asc(""&& Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;"j"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
else if (Asc(mystr) >&#61; Asc(""&& Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;"k"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
else if (Asc(mystr) >&#61; Asc(""&& Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;"l"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
else if (Asc(mystr) >&#61; Asc(""&& Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;"m"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
else if (Asc(mystr) >&#61; Asc(""&& Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;"n"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
else if (Asc(mystr) >&#61; Asc(""&& Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;"o"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
else if (Asc(mystr) >&#61; Asc(""&& Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;"p"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif 
else if (Asc(mystr) >&#61; Asc(""&& Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;"q"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
else if (Asc(mystr) >&#61; Asc(""&& Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;"r"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
else if (Asc(mystr) >&#61; Asc(""&& Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;"s"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
else if (Asc(mystr) >&#61; Asc(""&& Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;"t"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
else if (Asc(mystr) >&#61; Asc(""&& Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;"w"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif
else if (Asc(mystr) >&#61; Asc(""&& Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;"x"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
else if (Asc(mystr) >&#61; Asc(""&& Asc(mystr) < Asc("")) 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;"y"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
else if (Asc(mystr) >&#61; Asc("") ) 
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif
InBlock.gif    tt
&#61;"z"
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif
InBlock.gif   
else 
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    tt
&#61;mystr; 
InBlock.gif    
return tt; 
ExpandedSubBlockEnd.gif   }
 
ExpandedSubBlockEnd.gif  }
 
InBlock.gif  
private int Asc(String Mystr) 
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif
InBlock.gif   
int inttemp; 
InBlock.gif   
byte[] array &#61; new byte[2]; 
InBlock.gif   array 
&#61; System.Text.Encoding.Default.GetBytes(Mystr); 
InBlock.gif   
int i1 &#61; (short)(array[0- &#39;\0&#39;); 
InBlock.gif   
int i2 &#61; (short)(array[1- &#39;\0&#39;); 
InBlock.gif   inttemp
&#61;Convert.ToInt32(i1.ToString() &#43; i2.ToString()); 
InBlock.gif   
return inttemp; 
ExpandedSubBlockEnd.gif  }
 
InBlock.gif
public String TransPinYin(String strInf) 
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif
InBlock.gif   String strTemp
&#61;""
InBlock.gif   
int iLength&#61;strInf.Length; 
InBlock.gif   
for (int i&#61;0;i<&#61;iLength-1;i&#43;&#43;
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif
InBlock.gif    strTemp
&#43;&#61;PinYin(strInf.Substring (i,1)); 
ExpandedSubBlockEnd.gif   }
 
InBlock.gif   
return strTemp; 
InBlock.gif
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockEnd.gif }
 
ExpandedBlockEnd.gif}
 
ExpandedBlockStart.gifContractedBlock.gif
/**////// 
None.gif在程序中调用可用下面代码 
None.gif
private void button1_Click(object sender, System.EventArgs e) 
ExpandedBlockStart.gifContractedBlock.gif  
dot.gif
InBlock.gif   PinYinClass py
&#61;new PinYinClass(); 
InBlock.gif   textBox2.Text
&#61;py.TransPinYin(textBox1.Text); 
ExpandedBlockEnd.gif  }
 
ExpandedBlockStart.gifContractedBlock.gif
/**//
None.gif当然现阶段求出的是小写,你也可转成大写! 
None.gif


 


转:https://www.cnblogs.com/gwazy/archive/2005/03/02/111126.html



推荐阅读
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • JavaScript和HTML之间的交互是经由过程事宜完成的。事宜:文档或浏览器窗口中发作的一些特定的交互霎时。能够运用侦听器(或处置惩罚递次来预订事宜),以便事宜发作时实行相应的 ... [详细]
  • REVERT权限切换的操作步骤和注意事项
    本文介绍了在SQL Server中进行REVERT权限切换的操作步骤和注意事项。首先登录到SQL Server,其中包括一个具有很小权限的普通用户和一个系统管理员角色中的成员。然后通过添加Windows登录到SQL Server,并将其添加到AdventureWorks数据库中的用户列表中。最后通过REVERT命令切换权限。在操作过程中需要注意的是,确保登录名和数据库名的正确性,并遵循安全措施,以防止权限泄露和数据损坏。 ... [详细]
  • 本文分析了Wince程序内存和存储内存的分布及作用。Wince内存包括系统内存、对象存储和程序内存,其中系统内存占用了一部分SDRAM,而剩下的30M为程序内存和存储内存。对象存储是嵌入式wince操作系统中的一个新概念,常用于消费电子设备中。此外,文章还介绍了主电源和后备电池在操作系统中的作用。 ... [详细]
  • Java图形化计算器设计与实现
    本文介绍了使用Java编程语言设计和实现图形化计算器的方法。通过使用swing包和awt包中的组件,作者创建了一个具有按钮监听器和自定义界面尺寸和布局的计算器。文章还分享了在图形化界面设计中的一些心得体会。 ... [详细]
  • EPICS Archiver Appliance存储waveform记录的尝试及资源需求分析
    本文介绍了EPICS Archiver Appliance存储waveform记录的尝试过程,并分析了其所需的资源容量。通过解决错误提示和调整内存大小,成功存储了波形数据。然后,讨论了储存环逐束团信号的意义,以及通过记录多圈的束团信号进行参数分析的可能性。波形数据的存储需求巨大,每天需要近250G,一年需要90T。然而,储存环逐束团信号具有重要意义,可以揭示出每个束团的纵向振荡频率和模式。 ... [详细]
  • Spring源码解密之默认标签的解析方式分析
    本文分析了Spring源码解密中默认标签的解析方式。通过对命名空间的判断,区分默认命名空间和自定义命名空间,并采用不同的解析方式。其中,bean标签的解析最为复杂和重要。 ... [详细]
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • 本文介绍了数据库的存储结构及其重要性,强调了关系数据库范例中将逻辑存储与物理存储分开的必要性。通过逻辑结构和物理结构的分离,可以实现对物理存储的重新组织和数据库的迁移,而应用程序不会察觉到任何更改。文章还展示了Oracle数据库的逻辑结构和物理结构,并介绍了表空间的概念和作用。 ... [详细]
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • Voicewo在线语音识别转换jQuery插件的特点和示例
    本文介绍了一款名为Voicewo的在线语音识别转换jQuery插件,该插件具有快速、架构、风格、扩展和兼容等特点,适合在互联网应用中使用。同时还提供了一个快速示例供开发人员参考。 ... [详细]
  • 本文详细介绍了在ASP.NET中获取插入记录的ID的几种方法,包括使用SCOPE_IDENTITY()和IDENT_CURRENT()函数,以及通过ExecuteReader方法执行SQL语句获取ID的步骤。同时,还提供了使用这些方法的示例代码和注意事项。对于需要获取表中最后一个插入操作所产生的ID或马上使用刚插入的新记录ID的开发者来说,本文提供了一些有用的技巧和建议。 ... [详细]
  • 本文介绍了在Ubuntu下制作deb安装包及离线安装包的方法,通过备份/var/cache/apt/archives文件夹中的安装包,并建立包列表及依赖信息文件,添加本地源,更新源列表,可以在没有网络的情况下更新系统。同时提供了命令示例和资源下载链接。 ... [详细]
  • 本文介绍了在Ubuntu系统中清理残余配置文件和无用内容的方法,包括清理残余配置文件、清理下载缓存包、清理不再需要的包、清理无用的语言文件和清理无用的翻译内容。通过这些清理操作可以节省硬盘空间,提高系统的运行效率。 ... [详细]
author-avatar
拍友2502899521
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有