lamont Posted October 29, 2014 Share Posted October 29, 2014 (edited) arkadaşlar dizilerde indexof metoduyla dizide salıyı aratmaya çalışıyorum dizileri sıralıyor lakin indexof çalışmıyor sadece diziler sıralanıyor sorun nedir? private void button1_Click(object sender, EventArgs e) { int j = 0; string[] gunler = { "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi", "Pazar" }; j =Array.IndexOf(gunler, "Salı"); for (int i = j = 0; j < gunler.Count(); j++) { listBox1.Items.Add(gunler[j].ToString()); } } } } Edited October 29, 2014 by lamont Quote Link to comment Share on other sites More sharing options...
KintaRo Posted October 29, 2014 Share Posted October 29, 2014 sen for döngüsünü karıştırmışsın biraz int j = 0; string[] gunler = { "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi", "Pazar" }; j =Array.IndexOf(gunler, "Salı"); MessageBox.Show(gunler[j]); bu şekilde yaptığında önce salı'nın indexini alırsın, sonra messagebox ile o indexteki veriyi geri çağırabilirsin. for döngüsünü neden kullandın ayrıca, for döngüsüne j'yi neden karıştırdın. bir önceki örneğinde wolfman uyarmış seni, onun dediği yol doğru idi. Quote Link to comment Share on other sites More sharing options...
hophop Posted October 29, 2014 Share Posted October 29, 2014 (edited) Senin verdiğin kodda index of çalışıyor. sen ne yapmak istiyorsun. Günleri sıralayıp salı yımı seçmek istiyorsun private void button1_Click(object sender, EventArgs e) { int j = 0; string[] gunler = { "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi", "Pazar" }; j = Array.IndexOf(gunler, "Salı"); for (int i = 0; i < gunler.Count(); i++) { listBox1.Items.Add(gunler[i].ToString()); } listBox1.SelectedIndex = j; } Edited October 29, 2014 by hophop Quote Link to comment Share on other sites More sharing options...
KintaRo Posted October 29, 2014 Share Posted October 29, 2014 arkadaşlar kodları code /code tag'ı içinde vermeye özen gösterelim. Quote Link to comment Share on other sites More sharing options...
lamont Posted October 29, 2014 Author Share Posted October 29, 2014 günleri sıralıyor lakin mesala salı seçtim listbox salı kaçıncı sırada oldugunu göstermiyor yani 1 yazmıyor onu anlayamadım Quote Link to comment Share on other sites More sharing options...
hophop Posted October 29, 2014 Share Posted October 29, 2014 Kardeş senin odaklanma sorunun var bence. Zaten j değişkenine index of ile atıyorsun sırasını. Message box ile ekranda uyarı olarak göster. Quote Link to comment Share on other sites More sharing options...
lamont Posted October 29, 2014 Author Share Posted October 29, 2014 messagebox degil listbox en üst kısımda göstersin istiyorum çünkü egitim setin consol ekranında en üst kısımda 1 yazıyor aşagıda ise günler sıralanmış Quote Link to comment Share on other sites More sharing options...
hophop Posted October 29, 2014 Share Posted October 29, 2014 O zaman kardeş ne olmasını istiyorsan bunu resimli bir şekilde göster bizde ona göre yardımcı olalım. Çünkü istediğim şeyleri biraz eksik anlatıyrosun. Quote Link to comment Share on other sites More sharing options...
lamont Posted October 29, 2014 Author Share Posted October 29, 2014 kardeş bak resim deki gibi en üste hangi sırada oldugun belirmiş aşagıdaki kodla j atana n salıyı seçili geliyor listBox1.SelectedIndex = j; Quote Link to comment Share on other sites More sharing options...
KintaRo Posted October 29, 2014 Share Posted October 29, 2014 kardeş sen video falan çek ya, gene anlamadık valla. Quote Link to comment Share on other sites More sharing options...
WolfmanTR_ Posted October 29, 2014 Share Posted October 29, 2014 Şuan senin problemin nedir bunu anlasak sorunu çözeceğiz.ya sen anlatamıyorsun yada biz anlamıyoruz senin dilini :facepalm: Quote Link to comment Share on other sites More sharing options...
lamont Posted October 29, 2014 Author Share Posted October 29, 2014 yukarıdaki resimde consol ekranında en üste (1) yazıyor yani salı demek indexof metoduyla bende listbox içinde salı yı aynı şekilde yazdırmak istiyorum listbox içinde en üste hangi sıradaki gün seçilirse o günün sayısını vermesi gerekiyor aşagıdaki resimdeki kod ve consol erkanındaki bakın Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted October 29, 2014 Editor Share Posted October 29, 2014 int j = 0; string[] gunler = { "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi", "Pazar" }; j =Array.IndexOf(gunler, "Salı"); listBox1.Items.Add(j.ToString()); for (int i = j = 0; j < gunler.Count(); j++) { listBox1.Items.Add(gunler[j].ToString()); } Quote Link to comment Share on other sites More sharing options...
lamont Posted October 29, 2014 Author Share Posted October 29, 2014 (edited) Pairs kardeşime çok tşk ederim sorunu çözüme kavuşturdum hatam ise index of tan sonra listbox aktarmadıgım için ben j yi döngüden sonra listbox aktatrır diye düşünmüştüm Pairs sayesinde sorunu çözdüm çok tşk ederim tüm pairs ve diger arkadaşlara j =Array.IndexOf(gunler, "Salı"); listBox1.Items.Add(j.ToString()); Edited October 30, 2014 by lamont Quote Link to comment Share on other sites More sharing options...
lamont Posted October 30, 2014 Author Share Posted October 30, 2014 (edited) arkadaşlar dizilerde array copy kullanıyorum copy bütün dizileri alıyor lakin sadece diziden bazı sadece çarşambaya kadar olanı almak istiyorum ama listbox içinde sıralatamadım alt alta kopyaladım listboxları [0] [1] [2] [3] [4] şeklince altalta sıraladım olmadı consol ekranın oluyor ama listbox sıkıntılı array copy nasıl kullanabilirim private void button1_Click(object sender, EventArgs e) { string[] gunler = { "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi", "Pazar" }; string [] d = new string[7]; Array.Copy(gunler, d, 5); for (int i =0; i < gunler.Count(); i++) { listBox1.Items.Add(d[i].ToString()); } } } } arkadaşlar yardımcı olaiblirmsiniz Edited October 30, 2014 by lamont Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted October 30, 2014 Editor Share Posted October 30, 2014 gunler.Count() -1 yap dünde söyledim. index 0 dan başlar. Quote Link to comment Share on other sites More sharing options...
lamont Posted October 30, 2014 Author Share Posted October 30, 2014 Pairs array.Copy komutu listbox sorun veriyor sorun array copy listboxta verilen degeri sıralamıyor Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted October 30, 2014 Editor Share Posted October 30, 2014 Çarşamba sıralamaya koyarsan 2. sırada 0 - Pazartesi 1 - Salı 2 - Çarşamba sen bu dizeden çarşambaya kadar olanını listelemek istiyorsun. o halde Array.Copy(gunler, 0,d,0,2 ); copy komutun bu şekilde olacak. Yani gunler dizesinden 0 dan başla 2 . elemana kadar kopyala. Quote Link to comment Share on other sites More sharing options...
lamont Posted October 30, 2014 Author Share Posted October 30, 2014 Pairs hata ne yaparsam yapim bu şekilde sorun yaşıyorum Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted October 30, 2014 Editor Share Posted October 30, 2014 string[] gunler = new string[6] gunler[0] = "Pazartesi"; gunler[1] = "Salı"; gunler[2] = "Çarşamba"; gunler[3] = "Perşembe"; gunler[4] = "Cuma"; gunler[5] = "Cumartesi"; gunler[6] = "Pazar"; bu şekilde tanımlayıp denermisin gunler i. Quote Link to comment Share on other sites More sharing options...
lamont Posted October 30, 2014 Author Share Posted October 30, 2014 Pairs 2 dk team bakabilirmisin yoksa ben kafayı yiyecem Quote Link to comment Share on other sites More sharing options...
KintaRo Posted October 30, 2014 Share Posted October 30, 2014 http://www.tnctr.com/forum/100-autoplay-media-studio/ bir düşün derim. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.