Split string, convert ToList() in one line

var numbers = sNumbers?.Split(',')?.Select(Int32.Parse)?.ToList();

Recent versions of C# (v6+) allow you to do null checks in-line using the null-conditional operator

Leave a Comment