Today I needed to get a list of UserIds which are stored in the web.config file, separated by commas, in one string.
The below method makes use of Linq to achieve this in a neat solution.
string StringOfUsers = "8,4,5,20,15";
List<int> ListOfUsers = new List<int>();
if ((!string.IsNullOrEmpty(StringOfUsers))) {
ListOfUsers = StringOfUsers.Split(",").Select(s => int.Parse(s)).ToList();
}
return ListOfUsers;
Tags
c# (3)
Statiq (3)
General (2)
javascript (1)
Azure (1)
Penny Pinching (1)
asp.net (1)
MSSQL (1)
Windows (1)
jQuery (1)
Share this
TweetConnect with me
Tweets by TryingToCode