因为我是一个该死的初学者,所以我需要一些帮助:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Gauss_Algorithmus
{
class Program
{
static void Main(string[] args)
{
if (x1 > 0 && x2 > 0)
{
x02 = (x2 * x1) - (x1 * x2);
y02 = (y2 * x1) - (x1 * y2);
z02 = (z2 * x1) - (x1 * z2);
d02 = (d2 * x1) - (x1 * d2);
}
Console.WriteLine("2.: " + x02 + "x + " + y02 + "y + " + z02 + " d02);
}
}
它说:
使用未分配的局部变量“x01等......”
我了解该错误并知道x01
只是在本地范围内定义,但不知道如何修复它,因为x01
等需要在内部定义if
loop.
我希望你们能帮助我,先谢谢你们了。
最好的建议是编写 C# 入门教程。
具体回答你的问题有两点错误:
- 您需要声明变量。基本上使用
var x02 = (x2 * x1) - (x1 * x2);
etc
- 变量的使用需要在同一范围内。要么你必须移动
Console.WriteLine
在 - 的里面if
块或者您需要在之前声明并初始化变量if
像这样的块:var x02 = 0;
etc
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)