Bir değişken yalnızca bir metin kutusu boş değilse nasıl atayabilirim?Sadece bir metin kutusu boş değilse bir vairable nasıl geçilir C#
Metin kutusuna & önekine bir metin eklemeye çalışıyorum ve boş değilse, metni bir dize değişkenine atayın ve bir metin dosyasına yazın. Metin kutusu boşsa, değişken oluşturulmamalı ve metin dosyasından çıkarılmamalıdır. Sorun o metin kutusu mesafesindedir
W S U4 V E2 Ben T7
5012G65 P9811Y10C2F4H4Q4: Bu örnek, bütün değişkenler ile oluşturulan ana dizeyi olduğu boş, önek harfi hala metin dosyasına (kalın) çıktı (boş ise hiç görünmemelidir).
Şimdiden teşekkürler.
kodum: Aşağıdaki gibi:
if (radioButton1.Checked == true)
{
string X = "X" + textBox1.Text.ToString();
string C = "C" + textBox2.Text.ToString();
string F = "F" + textBox3.Text.ToString();
string H = "H" + textBox4.Text.ToString();
string Q = "Q" + textBox5.Text.ToString();
string S = "S" + textBox6.Text.ToString();
string U = "U" + textBox7.Text.ToString();
string V = "V" + textBox8.Text.ToString();
string E = "E" + textBox9.Text.ToString();
string I = "I" + textBox10.Text.ToString();
string T = "T" + textBox11.Text.ToString();
string W = "W" + textBox12.Text.ToString();
string P9811A = string.Format("G65Y9811{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}", X, C, F, H, Q, S, U, V, E, I, T, W);
string[] lines = {"5000O8011",
"5001(OSAMPLE)",
"5007(SINGLE)",
"5008(CHANGE ALL VALUES BEFORE RUNNING)",
"5012" + P9811A,
"5013M01",
"(CORRECT ALL)",
};
System.IO.File.WriteAllLines(@"C:\WriteLines.txt", lines);
}
Teşekkürler beyler! Genel olarak büyük bilgi.şerefe – HGtez
Hoşgeldiniz @HGtez. –