Tiny way to get the first 25 characters

后端 未结 12 1557
感动是毒
感动是毒 2020-12-29 13:12

Can anyone think of a nicer way to do the following:

public string ShortDescription
{
    get { return this.Description.Length <= 25 ? this.Description :          


        
12条回答
  •  無奈伤痛
    2020-12-29 13:55

    return this.Description.Substring(0, Math.Min(this.Description.Length, 25));
    

    Doesn't have the ... part. Your way is probably the best, actually.

提交回复
热议问题