Quantcast
Viewing latest article 6
Browse Latest Browse All 6

Boşluk kontrol methodu

Merhaba arkadaşlar

Textboxtan aldığım veride boşluk kontrolü yapan bir methodum var birinci yöntemde string olarak genel değer olarak alıyorum çalışmıyor ikinci yöntemde ise textbox olarak nesne tanımlıyorum sonuc döndürüyor anlayamadım 

public static void boslukkontrol(string txt) { string sonuc=""; for (int i = 0; i < txt.Length; i++) { if (txt.Substring(i, 1) != " ") { sonuc = sonuc + txt.Substring(i, 1); } } txt = sonuc;

  private void button3_Click_1(object sender, EventArgs e)
        {  ortakmethod.boslukkontrol(textBox1.Text);  }

2. ikinci yöntem ile yapınca oluyor o da şöyle 

public static void boslukkontrol(TextBox txt) { string sonuc=""; for (int i = 0; i < txt.TextLength; i++) { if (txt.Text.Substring(i, 1) != " ") { sonuc = sonuc + txt.Text.Substring(i, 1); } } txt.Text = sonuc; }

   private void button3_Click_1(object sender, EventArgs e)
        {  ortakmethod.boslukkontrol(textBox1);  }





 


Viewing latest article 6
Browse Latest Browse All 6


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>