MVC - Split string
by
Jeremy Canfield |
Updated: March 20 2020
| MVC articles
In this example, we create a varable called MyString that contains the text "Hellow from MVC application." We then split the string, where a single space is the delimiter. Finally, we use a foreach loop to iterate through each word that was split.
@{
string MyString = "Hello from MVC application";
string[] SplitString = MyString.Split(' ');
foreach (string words in SplitString)
{
<p>@words</p>
}
}
Did you find this article helpful?
If so, consider buying me a coffee over at