2016-04-07 29 views
-1

Konsol çıktısını Visual Studio'daki bir liste görünümüne nasıl listeleyebilirim? Ben Kod neden konsola sonuçları gönderiyor,Liste görünümüne konsol çıktısı

foreach (IListBlobItem item in container.ListBlobs(null, false)) 
{ 
if (item.GetType() == typeof(CloudBlockBlob)) 
{ 
    CloudBlockBlob blob = (CloudBlockBlob)item; 

    Console.WriteLine("Block blob of length {0}: {1}", blob.Properties.Length, blob.Uri); 

} 
else if (item.GetType() == typeof(CloudPageBlob)) 
{ 
    CloudPageBlob pageBlob = (CloudPageBlob)item; 

    Console.WriteLine("Page blob of length {0}: {1}", pageBlob.Properties.Length, pageBlob.Uri); 

} 
else if (item.GetType() == typeof(CloudBlobDirectory)) 
{ 
    CloudBlobDirectory directory = (CloudBlobDirectory)item; 

    Console.WriteLine("Directory: {0}", directory.Uri); 
} 

} bir pencere formu bir Win uygulaması ise

+0

Sen operatörü 'olarak' kod daha okunaklı hale ve biraz iyileştirmek için performansı kullanabilirsiniz (Nihayet sonuçlarını görüntülemek için böyle bir kod kullanmak https://msdn.microsoft.com/en-us/library/cscsdfbt.aspx) –

cevap

0

olduğu gibi

Ben sonuçları göremiyorum?

Yukarıdaki kodun başına List<string> results = new List<string>(); ekleyebilir, ardından her Console.WriteLine'u results.Add ile değiştirebilirsiniz. Eğer bir ListView varsa

StringBuilder sb = new StringBuilder(); 
    foreach (string s in results) 
    { 
     sb.Append(Environment.NewLine); 
     sb.Append(s); 
    } 

    MessageBox.Show(sb.ToString(), "Results"); 

ya,:

foreach (string s in results) 
{ 
    listView1.Items.Add(s); 
} 
İlgili konular