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

  • martin shervington

    martin sherv

    7 EKİM 2011
  • modica89

    modica89

    24 HAZİRAN 2007
  • TWiT Netcast Network

    TWiT Netcast

    27 EKİM 2005