Neuruss wrote: > I'm sorry for asking about another language here, but since I only know > Python and I'm trying to write something in C#, I guess this is the > best place... > > I'd like to know how to write this in C#: > > x=[] > sz = 10000000 > x.extend(range(sz)) > > My question is about "range" and "extend". Is there any equivalent in > C#? > > Thanks in advance, > Neuruss >
List<int> mylist = new List<int>(); for (int i=0; i<10000000; i++) { mylist.Add(i); } You can use AddRange, C# 2.0 anonymous delegates, IEnumerable, yield, foreach, and so forth instead, but for your example this is simplest. Another option is to use boo. http://boo.codehaus.org/ It uses python's syntax but is as fast as C#. The only change you'd have to make in that code is to capitalize the Extend method call. -- http://mail.python.org/mailman/listinfo/python-list