我正在通过C#进行euler项目来学习语言并在暑假期间保持我的编码技能(我是大学生).所以我对这门语言很新.我试图寻找这个错误的答案,但我找到的所有其他类似问题都没有处理while循环.有问题的代码是:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EulerProblems
{
class Problem2
{
List<int> fib = new List<int>();
bool notAtLimit = true;
while(notAtLimit)
{
//code to populate list of fibonacci series
}
}
}
Run Code Online (Sandbox Code Playgroud)
您不能直接在类中编写代码.你需要在一个方法中写出它,例如
private void Test()
{
List<int> fib = new List<int>();
bool notAtLimit = true;
while (notAtLimit)
{
//code to populate list of fibonacci series
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
66 次 |
| 最近记录: |