Jump to content

Panelde Try Catch İf Değimiyle Birlikte Kullanım


MasterTR
 Share

Recommended Posts

[code]string ad, sifre;
ad = textBox1.Text;
sifre = textBox2.Text;
if (ad == "" && sifre == "")
{
MessageBox.Show("TMM");
}
else
{
MessageBox.Show("HAYIR");
}
}

catch (Exception)
{
MessageBox.Show("Sayısal");
}[/code]

sayısal ifade girince Catch bölümü devreye girmiyor. normalde ikiside string yani karakter sayısal ifade girsem bile karakter olarak algılıyor çözemedim. Edited by MasterTR
Link to comment
Share on other sites

[codebox]

string ad = textBox1.Text;

int sifre = int.Parse(textBox2.Text);

if (ad == "" && sifre == "")

{

MessageBox.Show("TMM");

}

else

{

MessageBox.Show("HAYIR");

}

}



catch (Exception)

{

MessageBox.Show("Sayısal");

}[/codebox]


burada şifre textini int değerinde aldım. şifre bölümüne sayısal olmayan bir değer girilirse catch bölümü çalışır. ama ad kısmında ister string ister int girilsin birşey değişmiyecektir.

Link to comment
Share on other sites

[b]Operator '==' cannot be applied to apperands of type int and string. [/b]
Dediğin yöntemi denediğimde zaten o hatayı [u]alıyordum[/u] galetis arkadaşım ben onu [u]denemiştim[/u] [u]İf bölümünd[/u]e bu sorun çıkıyor. :)

Edited by MasterTR
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...