lamont Posted October 28, 2014 Share Posted October 28, 2014 koddaki hatanın sebebi nedir private void button1_Click(object sender, EventArgs e) { string[] klasor; klasor= Directory.GetDirectories("c:/"); for (int i = 0; i < klasor.Length; i++); { MessageBox.Show(klasor[i].ToString()); } } } } hata Error 1 The name 'i' does not exist in the current context Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted October 28, 2014 Editor Share Posted October 28, 2014 string[] klasor; altına int i = 0; yaz Quote Link to comment Share on other sites More sharing options...
lamont Posted October 28, 2014 Author Share Posted October 28, 2014 pairs bu hatayı aldım Error 2 A local variable named 'i' cannot be declared in this scope because it would give a different meaning to 'i', which is already used in a 'parent or current' scope to denote something else c:\users\asus\documents\visual studio 2012\Projects\WindowsFormsApplication2\WindowsFormsApplication2\Form1.cs 27 22 WindowsFormsApplication2 sorunu kodu bu şekilde yaparak çözdüm ama program çalıştırınca butona tıkalyınca hiç bir işlem yapmıyor donuyor kalıyor private void button1_Click(object sender, EventArgs e) { string[] klasor; int j = 0; klasor= Directory.GetDirectories("C:/"); for (int i = j; i < klasor.Length; j++); { listBox1.Items.Add(klasor[j].ToString()); } } } } Quote Link to comment Share on other sites More sharing options...
galetis Posted October 28, 2014 Share Posted October 28, 2014 string[] klasor = Directory.GetDirectories("c:/"); for (int i = 0; i < klasor.Length; i++) { MessageBox.Show(klasor[i].ToString()); } Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted October 28, 2014 Editor Share Posted October 28, 2014 değişkeni j olarak oluşturuyorsun for döngüsünde i kullanıyorsun. Biraz dikkat edersen sorunu çözeceksin. Quote Link to comment Share on other sites More sharing options...
lamont Posted October 28, 2014 Author Share Posted October 28, 2014 galetis o şekilde hata alıyorum yukarıda belirtigim gibi Quote Link to comment Share on other sites More sharing options...
WolfmanTR_ Posted October 28, 2014 Share Posted October 28, 2014 değişkende j , döngüde i yazmışsın Quote Link to comment Share on other sites More sharing options...
lamont Posted October 28, 2014 Author Share Posted October 28, 2014 (edited) düzelttim arkadaşlar aşagıdaki gibi sorunla karşılaştım Edited October 28, 2014 by lamont Quote Link to comment Share on other sites More sharing options...
galetis Posted October 28, 2014 Share Posted October 28, 2014 Tam olarak yazdığımı kopyalayıp yapıştırırsan çalışacaktır. Virgül hatası yapmışsın. Quote Link to comment Share on other sites More sharing options...
lamont Posted October 28, 2014 Author Share Posted October 28, 2014 (edited) eywallah sorunu buldum for döngüsünden sonra (noktalı virgül) kullanmışım hiç dikkat etmemişim tşk ederim arkadaşlar inşallah kısa zaman C# ögrenirim herkese kolay gelsin :) Edited October 28, 2014 by lamont Quote Link to comment Share on other sites More sharing options...
WolfmanTR_ Posted October 28, 2014 Share Posted October 28, 2014 int j =0; (for int = j ; ............. yapmak yerine (for int i = 0 yapmak mantıklı değil mi ? Quote Link to comment Share on other sites More sharing options...
lamont Posted October 29, 2014 Author Share Posted October 29, 2014 wolfman öyle hata veriyor neden hata veriyor anlamadım yani verdigi hata ise degişkene deger atamalısın diyor senin yaptıgın gibi degişkene deger atıyorum i=0; diyorum hata alıyorum ama i=j; dersem yapmak istedigim oluyor ??? 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.