首页 > 解决方案 > C#如何让应用程序接收我的输入

问题描述

我试图在 C# 中做一个简单的控制台应用程序,我输入一个值以在控制台中打印出相同数量的星星。例如,如果我输入值 5 i 控制台,我希望它打印出 5 颗星: *****

1 => *

2 => **

3 => ***

编辑:

enter using System; 

using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace kvadrat { class Program { static void Main(string[] args)

    {
        Console.Write("Hur stor kvadrat vill du ha? ");
        int size = Convert.ToInt32(Console.ReadLine());

        for (int y = 0; y < size; y++)
        {
            for (int x = 0; x < size; x++)
            {
                Console.Write("*");
            }
            Console.WriteLine("");
        }
        Console.ReadKey();
    }
}

}

标签: c#

解决方案


我得到了我的问题的答案。

        {
        Console.Write("Hur stor kvadrat vill du ha? ");
        int size = Convert.ToInt32(Console.ReadLine());

        for (int y = 0; y < size; y++)
        {
            for (int x = 0; x < size; x++)
            {
                Console.Write("*");
            }
            Console.WriteLine("");
        }
        Console.ReadKey();
    } code here

推荐阅读