📜  c# multiplicate char - C# (1)

📅  最后修改于: 2023-12-03 14:39:43.674000             🧑  作者: Mango

C# Multiplicate Char

C# Multiplicate Char is a simple C# program that multiplies a given character a specified number of times and returns the result.

Getting Started

To use the C# Multiplicate Char program, follow these steps:

  1. Open Visual Studio.
  2. Create a new C# Console Application project.
  3. In the Program.cs file, copy and paste the following code:
using System;
using System.Text;

namespace MultiplicateChar
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Enter a character: ");
            char c = Console.ReadKey().KeyChar;
            Console.Write("\nEnter the number of times to multiply the character: ");
            int times = int.Parse(Console.ReadLine());

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < times; i++)
            {
                sb.Append(c);
            }

            Console.WriteLine($"Result: {sb.ToString()}");
            Console.ReadKey();
        }
    }
}
  1. Save and run the program.
Usage

To use the C# Multiplicate Char program, simply enter a character and the number of times that you want to multiply it when prompted. The program will then return the result.

Enter a character: !
Enter the number of times to multiply the character: 5
Result: !!!!!
Conclusion

C# Multiplicate Char is a simple, yet useful program that can be used to quickly generate repeated characters. Whether you need to generate dummy data, create patterns, or just want to have some fun, this program is a great tool to have in your C# programming toolbox.