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

  • BSA

    BSA

    9 NİSAN 2012
  • cosmicrocketman

    cosmicrocket

    17 NİSAN 2006
  • Joseph Herscher

    Joseph Hersc

    14 Mart 2007