Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· openaiHugging Face Suzhen/CodeChat

give me c# code that wrap string in console in the double-lined border

  1. User

    give me c# code that wrap string in console in the double-lined border

  2. Assistant

    Sure, here's a simple C# code that wraps a string in the double-lined border when displayed in the console.

    using System;
    
    class Program
    {
        static void Main()
        {
            // String to be wrapped in double-lined border
            string input = "Hello, World!";
    
            // Calculate the required width for the border
            int width = input.Length + 4; // Add 4 for the boundary characters and spaces
    
            // Display the double-lined border
            Console.WriteLine(new string('=', width));
    
            // Display the wrapped string with the border
            Console.WriteLine($"|| {input} ||");
    
            // Display the double-lined border
            Console.WriteLine(new string('=', width));
        }
    }
    

    When you run this code, it will output the provided string wrapped in a double-lined border in the console:

    ================
    || Hello, World! ||
    ================