任何人都可以想到一个更好的方法来做到以下几点:
public string ShortDescription
{
get { return this.Description.Length <= 25 ? this.Description : this.Description.Substring(0, 25) + "..."; }
}
Run Code Online (Sandbox Code Playgroud)
我本来希望只做string.Substring(0,25),但如果字符串小于提供的长度,它会引发异常.