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

  • Garrett Müller

    Garrett Mül

    26 HAZİRAN 2009
  • How to Cook ?

    How to Cook

    31 Ocak 2007
  • Vintendo Power

    Vintendo Pow

    2 Ocak 2007