@(string.Format("{0}", Model.Toxin[i].intake_link[0].Length > 30 ?Model.Toxin[i].intake_link[0].Substring(0, 30) : Model.Toxin[i].intake_link[0])
But I suggest you write some string extension and use it:
public static string TrimToMaxLength(this string value, int maxLength)
{
return (value == null || value.Length <= maxLength ? value : value.Substring(0, maxLength));
}
and then use anywhere:
Model.Toxin[i].intake_link[0].TrimToMaxLength(30)