user3568783
user3568783

Reputation:

How can I make a List<string> into a string[] using LINQ?

I have this code that returns a List

   var addRoles = newRoles
      .Where(x => oldRoles
      .All(y => y != x))
      .ToList();

I am using this in a method however the method requires a string array:

string[]

How can I make the addRoles variable into a string array?

Upvotes: 0

Views: 35

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222582

Use ToArray()

var addRoles = newRoles
      .Where(x => oldRoles
      .All(y => y != x))
      .ToArray();

Upvotes: 2

Related Questions