SORU
21 EKİM 2009, ÇARŞAMBA


Sistem dönüşümü.Dizi Listesine

Dün gece aşağıdaki imkansız olduğunu bir rüya gördüm. Ama aynı rüya, bu YÜZDEN birisi bana aksini söyledi. Dolayısıyla bunu bilmek mümkün List System.Array dönüştürmek istiyorum

Array ints = Array.CreateInstance(typeof(int), 5);
ints.SetValue(10, 0);
ints.SetValue(20, 1);
ints.SetValue(10, 2);
ints.SetValue(34, 3);
ints.SetValue(113, 4);

için

List<int> lst = ints.OfType<int>(); // not working

CEVAP
21 EKİM 2009, ÇARŞAMBA


Kendine acı... Kaydet

int[] ints = new [] { 10, 20, 10, 34, 113 };

List<int> lst = ints.OfType<int>().ToList(); // this isn't going to be fast.

Ayrıca sadece...

List<int> lst = new List<int> { 10, 20, 10, 34, 113 };

ya da...

List<int> lst = new List<int>();
lst.Add(10);
lst.Add(20);
lst.Add(10);
lst.Add(34);
lst.Add(113);

ya da...

List<int> lst = new List<int>(new int[] { 10, 20, 10, 34, 113 });

ya da...

var lst = new List<int>();
lst.AddRange(new int[] { 10, 20, 10, 34, 113 });

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:
C#

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Atlantic Records

    Atlantic Rec

    15 Aralık 2006
  • Gee Cee

    Gee Cee

    1 AĞUSTOS 2009
  • pendrop gaming

    pendrop gami

    4 ŞUBAT 2013