FreeKB - MVC Split string
MVC - Split string

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>
    }
}

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




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




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |