c# - 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();
}
}
}
解决方案
我得到了我的问题的答案。
{
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
推荐阅读
- google-apps-script - 如何使用新 Google 电子表格的数据填充特定工作表中的单元格
- makefile - 带有单独目录树中的对象的 Makefile
- git - 从开发分支检查最新提交的 Git 命令
- react-native - 播放 youtube 嵌入视频时反应原生 webview 崩溃
- docker - Docker化的反向代理
- c# - gmail不再发送电子邮件
- typescript - 打字稿:将类型定义为除函数之外的任何类型
- kotlin - 如何结合 JUnit4 @RunWith(Parameterized.class) 和 JUnit5 @ParameterizedTest
- asp.net - 无法从 Angular 将文件作为 FormData 上传到 ASP.net
- ruby-on-rails - 创建“本月”查询轨道