S
S
Sergey Karbivnichy2017-03-21 22:40:22
Programming
Sergey Karbivnichy, 2017-03-21 22:40:22

How to display text with parameters {0} in c# in TextBox?

I need to display a lot of text with a lot of variables in a TextBox, but I don't want to write a lot of plus signs and quotes so as not to get confused.

string myString = "World";
textBox1.Text = "Hello {0} !",myString;

This works in console applications, but not in WinForms! Maybe I'm stupid, but I can not understand something. Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tom Nolane, 2017-03-21
@hottabxp

add.
in c# (version 6) there is such an opportunity (not to use numbers):

string bla = "первое слово";
string bla2 = "второе слово";
textBox1.Text = string.Format($"({bla}, {bla2})"); //знак $ нужен для того, чтобы сказать, что тут именованные переменные нужно брать

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question