1

I have a substring which is defined as:

<p>@Html.Raw(item.Post.Substring(0, 300))...</p>

The text I'm entering far exceeds 300 characters, but I'm still getting the error above. I thought the second param on the substring method was supposed to be the number of characters you want to cut to?

Unless I'm wrong and I'm missing something?

Web Develop Wolf
  • 5,996
  • 12
  • 52
  • 101

1 Answers1

1

Try following

item.Post.Substring(0, Math.Min(300, item.Post.Length));
tchelidze
  • 8,050
  • 1
  • 29
  • 49