Jump to content

C# Degişken Hatası


lamont
 Share

Recommended Posts

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
 

 

Link to comment
Share on other sites

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());
           }
            
        }
    }
}
Link to comment
Share on other sites

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 ???

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...