split a string and use each item to assign to another list
<p>I have a list of roles to assign to users:</p>

<pre><code>var role1 = new Role { ApplicationName = "XXX", RoleName = "ROLE1" };
var role2 = new Role { ApplicationName = "XXX", RoleName = "ROLE2" };
var role3 = new Role { ApplicationName = "XXX", RoleName = "ROLE3" };

List&lt;Role&gt; listRoles = new List&lt;Role&gt;
{
    role1,
    role2,
    role3
};
</code></pre>

<p>I can assign a specific role like this:</p>

<pre><code>var userRoles = new List&lt;Role&gt; 
{
    listRoles.First(x =&gt; x.RoleName == "ROLE1")
}
</code></pre>

<p>Let's say I have a string with listed roles to add to my user</p>

<pre><code>string listRoles = "ROLE1;ROLE3";
</code></pre>

<p>My question: how can I assign a list of roles to my user?</p>

<p>I try:</p>

<pre><code>var userRoles = new List&lt;Role&gt; 
{
    foreach(var role in listRoles.Split(";")
    {
        listRoles.First(x =&gt; x.RoleName == role);
    }
}
</code></pre>

<p>I got compile error.</p>
