Jump to content

C# Textbox Boş Oldugunda Hata


lamont
 Share

Recommended Posts

arkadaşlar C# textbox ları boş geçtiginde hata mesajı ile boş geçmezsin hatasını yaparken hata alıyorum sorun nedir 

 

if (textbox1.text ="") messagebox.show ('textbox boş geçemezsiniz);'

 

aşagıdaki hatayı alıyorum 
 
Cannot implicitly convert type 'string' to 'bool'
Link to comment
Share on other sites

Tekeşittir koymuşsun o sıkıntı olmuş. iki tane eşittir koyucaksın if sorgusu içine

 

private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
                MessageBox.Show("Boş olmasın");
        }
Edited by alparslan
Link to comment
Share on other sites

 

söz dizimi yanlış olmuş

if (textbox1.Text == "")
{
    // boşsa çalışacak kodlar
}
else
{
    // boş değilse çalışacak kodlar
}

kintaro süs parentezin dışında  tanımlamışsın if döngüsünü ama alparslan kardeşin yaptı şekilde oldu parantezin dışında tanımladın ?

Link to comment
Share on other sites

kintaro süs parentezin dışında  tanımlamışsın if döngüsünü ama alparslan kardeşin yaptı şekilde oldu parantezin dışında tanımladın ?

@kintaro sana direk if döngüsünü böyle yaz demiş butonun içine yazmamış zaten o. Benim yaptığım işini görür

Link to comment
Share on other sites

alparslan ile benim yazdığım kodun bir farkı yok. if koşulunu parantezli de parantezsiz de kullanabilirsin. alparslan farklı bir şey yazmamış yani. sadece ben textBox1 yerine textbox1 yazdım. Projeyi açıp yazmadım. Visual Studio case sensitive olduğu için benim kodu kopyala yapıştır yaparsan hata alırsın. 

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