Зачем нужны метки {0}, {1} ну и такие метки | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Зачем нужны метки {0}, {1} ну и такие метки

3rd Jul 2019, 2:14 PM
FanTop
FanTop - avatar
2 Answers
+ 2
string s1 = "Привет "; string s2 = "FanTop"; Console.WriteLine("{0}" + "{1}", s1, s2); //Привет FanTop Где {0} и {1} маркеры подстановки, а s1 и s2 элементы подстановки ------------------------------ string s1 = "Hello "; string s2 = "FanTop"; Console.WriteLine("{0}" + "{1}", s1, s2); //Hello FanTop Where {0} and {1} substitution markers, s1 and s2 permutation elements
5th Jul 2019, 10:06 AM
Dmitry S.
Dmitry S. - avatar
+ 1
They are called placeholders. They hold the data you want to insert into the string. It is just a way of doing it. Strictly speaking you do not need it. You can use String concatenation Placeholders Or string interpolation There are several ways to do things right. https://code.sololearn.com/cZAfo3Y9ElXv/?ref=app
3rd Jul 2019, 6:19 PM
sneeze
sneeze - avatar