11.2 如何取得汉字的拼音或者拼音首字母缩写?
所在组件:IBeamMDAACore.dll
名称空间:IBeam.MDAA.Utility
用法举例: _Code =Chinese2Spell.GetHeadOfChs(_Name);
推荐用法,取拼音字母时放在ORM类中,可保证正确性:
#region 名称
protected string _Name;
/// <summary>
/// 名称
/// </summary>
[Property(NotNull = true, Length = ConstSetting.ShortVarchar)]
public string Name
{
get
{
return _Name;
}
set
{
_Name = value;
if (string.IsNullOrEmpty(_Name))
{
_Code = string.Empty;
}
else
{
_Code =Chinese2Spell.GetHeadOfChs(_Name);
}
}
}
#endregion
#region 拼音速记码
private string _Code;
/// <summary>
/// 拼音速记码
/// </summary>
[Property(Length = ConstSetting.ShortVarchar)]
public string Code
{
get { return _Code; }
set
{
_Code = value;
}
}
#endregion