using static System.Console;
public static void Main() {
Write($"|{("Hello World".PadBoth(42))}|");
public static class StringExt {
public static string PadBoth(this string str, int length, char character = ' ') => str.PadLeft((length - str.Length) / 2 + str.Length, character).PadRight(length, character);