MasterTR Posted June 19, 2011 Share Posted June 19, 2011 (edited) [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 June 19, 2011 by MasterTR Quote Link to comment Share on other sites More sharing options...
galetis Posted June 19, 2011 Share Posted June 19, 2011 Çünkü karakter olarak çekiyorsun. Textbox1.text olarak alırsan tabiki string olarak çeker. int.Parse yada Convert.toint32 kullanırsan sayı olarak çeker. Quote Link to comment Share on other sites More sharing options...
MasterTR Posted June 19, 2011 Author Share Posted June 19, 2011 [b]Demek istediğini anladım iF değimi izin vermiyor benim örneğimi düzenleyerek gösterebilirmisin?[/b] Quote Link to comment Share on other sites More sharing options...
galetis Posted June 19, 2011 Share Posted June 19, 2011 [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. Quote Link to comment Share on other sites More sharing options...
MasterTR Posted June 19, 2011 Author Share Posted June 19, 2011 (edited) [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 June 19, 2011 by MasterTR Quote Link to comment Share on other sites More sharing options...
galetis Posted June 19, 2011 Share Posted June 19, 2011 he k.bakma o zaman. başka sorun göremedim ben. 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.