Bootstrap FreeKB - MVC - Split string
MVC - Split string

Updated:   |  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 Buy Me A Coffee



Comments


Add a Comment


Please enter 601e63 in the box below so that we can be sure you are a human.