-1

im working at my own little Program so I wanted to ask how I can do the variable test to give out - so long how intro.Length is.

So the String intro is 66 chars with space long now I want that it prints just - 66 times like ---------------------------------------------- but 66 chars long how can I do that?

using System;

namespace ConsoleApp1
{
    class Program
    {
        public static int alter;
        public static string vorname;
        public static string nachname;
        public static string jeah;
        public static string intro;
        public static int abc;
        public static string test;

        static void Main(string[] args)
        {
            intro = "Hey you wanna try my small Program? If Yes enter Y if not enter N!";
            abc = intro.Length;
            test = "-" * ;

            Console.Write(test);
            jeah = Console.ReadLine();
            if (jeah == "Y")
            {
                Vorname();
                Nachname();
                Alter();
                Output();
            } else
            {
                Console.WriteLine("Schade dann nicht!");
            }

            
            Console.ReadKey();
        }
Leo
  • 23
  • 1
  • 6

1 Answers1

1

As simple as using the string's constructor like this :

string s = new string('-', 66);
Tim
  • 170
  • 10