C# String Substitution (Composite Formatting)

Composite formatting is a feature in C# that allows for string substitution using placeholders within a format string. This is useful for dynamically constructing strings with variables.

Example

string format = "{0} is {1} years old.";
string result = string.Format(format, "John", 30);
Console.WriteLine(result);  // Outputs "John is 30 years old."

Output:

John is 30 years old.

Code Explanation: The string.Format() method replaces the placeholders {0} and {1} with the arguments "John" and 30, respectively.