ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

To

Creates a range of integers as an IEnumerable<Int32>.

Source

public static IEnumerable<int> To(this int first, int last) {
  return Enumerable.Range(first, last - first + 1);
}

Example

var numbers = 1.To(10);

Author: Richard Bushnell

Submitted on: 3 mrt. 2008

Language: C#

Type: System.Int32

Views: 5290