string myList = “9,3,12,43,2”; List<int> intList = myList.Split(‘,’).Select(int.Parse).ToList();
string myList = “9,3,12,43,2”; List<int> intList = myList.Split(‘,’).Select(int.Parse).ToList();
List<int> list = new List<int>() {1,2,3}; string.Join<int>(“,”, list) Join has generic overloads. It is so much easier to use it in that way to convert your list to the different types.
string sNumbers = “1,2,3,4,5”; var numbers = sNumbers.Split(‘,’).Select(Int32.Parse).ToList();
Let’s say we have this values in the database: num — 1 2 4 5 6 8 9 11 To Find the first missing value, we can use this: ;WITH CteRN AS( SELECT *, RN = num – ROW_NUMBER() OVER(ORDER BY num) FROM tbl ) SELECT TOP 1 num – RN FROM CteRN WHERE RN […]
dataTable.DefaultView.ToTable(true, “target_column”); first parameter in ToTable() is a boolean which indicates whether you want distinct rows or not. second parameter in the ToTable() is the column name based on which we have to select distinct rows. Only these columns will be in the returned datatable. If you need to get distinct based on two columns: dataTable.DefaultView.ToTable(boolean, params string[] columnNames)
drpList.Items.Insert(0, new ListItem(String.Empty, String.Empty)); drpList.SelectedIndex = 0;