c# create list with range
// Adding value to existing list
var list = new List<int>();
list.AddRange(Enumerable.Range(1, x));
// Creating new list
var list = Enumerable.Range(1, x).ToList();
c# create list with range
// Adding value to existing list
var list = new List<int>();
list.AddRange(Enumerable.Range(1, x));
// Creating new list
var list = Enumerable.Range(1, x).ToList();
how to get a subset of a list in c#
using System;
using System.Linq;
public class MainClass
{
public static void Main()
{
int[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int offset = 0;
int length = 3;
var subArray = array.Skip(offset).Take(length).ToArray();
Console.WriteLine(String.Join(",", subArray));
}
}
/*
Output: 1,2,3, this will return the first elements of the array
*/
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us