public string GenerateBlock(int width, int height) { var sb = new StringBuilder(); for (int h = 0; h < height; h++) { var borderRow = h == 0 || h + 1 == height; for (int w = 0; w < width; w++) { var borderColumn = w == 0 || w + 1 == width; if (borderRow) sb.Append("="); else if (borderColumn) sb.Append("|"); else sb.Append("."); } sb.AppendLine(); } return sb.ToString(); } // Usage: Console.WriteLine(GenerateBlock(20, 10)); // Result: ==================== |..................| |..................| |..................| |..................| |..................| |..................| |..................| |..................| ====================
673900cookie-checkC# Generate string block