c# - C#While循环没有意外输出任何东西
问题描述
在我运行过程中遇到更多问题。这次我在论坛上环顾了几分钟以寻找答案,但没有成功找到任何东西(我的意思是其中大部分都包含更复杂的 while 循环方法,所以我不知道会发生什么。 ) 这里是 c# 代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CodingExcercise
{
class Program
{
static void Main(string[] args)
{
int answer;
int number;
Console.WriteLine("Type in the number you desire the multiplication table for!");
number = Convert.ToInt32(Console.ReadLine());
int count = 1;
while (count != 10) ;
answer = number * count;
Console.WriteLine("{0}*{1}={2}", number, count, answer);
count = count + 1;
}
}
}
这就是全部(我主要只是通过基本练习来进行这些操作)我正在尝试发布一个最多十的数字。
而且我在这里得到了更快的回复,然后查看所有已关闭的线程,直到找到正确的线程,如果已经有这样的线程,抱歉。谢谢!
解决方案
尝试使用这个:
static void Main(string[] args)
{
int answer;
int number;
Console.WriteLine("Type in the number you desire the multiplication table for!");
number = Convert.ToInt32(Console.ReadLine());
int count = 1;
while (count != 10)
{
answer = number * count;
Console.WriteLine("{0}*{1}={2}", number, count, answer);
count = count + 1;
}
Console.ReadLine();
}
推荐阅读
- java - 如何使用流 lambda 将包含其 Collection 成员的对象列表映射到具有 Set 作为成员的另一个对象?
- python - Matplotlib Legend 显示错误的图例名称
- c++ - 将列表迭代器存储为成员
- spring - 创建spring boot gradle mutli项目
- javascript - AJAX GET 命令以获取灯的状态
- python - 逐行构造pyarrow表的最快方法
- android - 如何在使用抽屉选项的 ListView 中更改所选项目的颜色
- python - Gale-shapley算法的python实现
- python-3.7 - 尝试使用 ListView 进行搜索时出现错误:“无法使用无作为查询值”
- c++ - Tryinig 在纯 c 中对 arduino 进行编程,得到以下错误:在 'Print'| 之前预期的 '='、','、';'、'asm' 或 '__attribute__'|