首页 > 解决方案 > 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;
    }
}
}

这就是全部(我主要只是通过基本练习来进行这些操作)我正在尝试发布一个最多十的数字。

而且我在这里得到了更快的回复,然后查看所有已关闭的线程,直到找到正确的线程,如果已经有这样的线程,抱歉。谢谢!

标签: c#visual-studio

解决方案


尝试使用这个:

 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();
    }

推荐阅读