.NET Fiddle

CSharp · Console

/Program.cs

using System;
using System.Linq;
using System.Collections.Generic;

public class Program
{
	public static void Main()
	{
		string baIds = "1,x,2";
		List<long ? > result = null;
		if (!string.IsNullOrEmpty(baIds))
		{
			long temp;
			result = baIds.Split(',').Select(e => long.TryParse(e, out temp) ? temp : (long ? )null).ToList();
		}

		foreach (long ? item in result)
		{
			Console.WriteLine(item.HasValue ? item.ToString() : "null");
		}
	}
}
;