C# 字串(String)與變數 組合/組裝/串接/合併/相加 [c# string insert variable]
C# 字串(String)與變數 組合/組裝/串接/合併/相加 [c# string insert variable]
資料來源:https://stackoverflow.com/questions/13033581/insert-variable-values-in-the-middle-of-a-string
線上編譯器:https://dotnetfiddle.net/
Code
//C# 6
string name = "John";
string result = $"Hello {name}";
//C# .net4X
string template = "Hi We have these flights for you: {0}. Which one do you want";
string data = "A, B, C, D";
string message = string.Format(template, data);