Предположим, у меня есть следующий код на Python (да, этот вопрос о C#, это всего лишь пример)
string = "{entry1} {entry2} this is a string"
dictionary = {"entry1": "foo", "entry2": "bar"}
print(string.format(**dictionary))
# output is "foo bar this is just a string"
В этой строке он заменит {entry1} и {entry2} из строки на foo и bar с помощью .format()
Можно ли в любом случае воспроизвести ТОЧНО то же самое на C# (а также удалить фигурные скобки), как показано в следующем коде:
string str1 = "{entry1} {entry2} this a string";
Dictionary dict1 = new() {
{"entry1", "foo"},
{"entry2", "bar"}
};
// how would I format this string using the given dict and get the same output?
Подробнее здесь: https://stackoverflow.com/questions/707 ... in-c-sharp