私はc#を学ぼうとしていますが、問題に遭遇し続けています。基本的に、私は何らかの機能を実行し、アプリケーションによってその機能を実行するために呼び出されるクラスを作成する方法を学ぼうとしています。
最終的に発生したエラー(他にもたくさんありますが、それらを「修正」するためにいろいろ試してみました)は
is a 'type' but is used like a variable
これまでにまとめたコードは次のとおりです。
namespace FirstConsoleApplication
{
class Program
{
public class checkConvertValue
{
public string formula1(string x)
{
Int32 isnumber = 0;
bool canConvert = Int32.TryParse(x, out isnumber);
string returnValue;
if (canConvert == true)
{
int val3 = Int32.Parse(x);
switch (val3)
{
case 50:
returnValue = "yep its 50";
break;
case 51:
returnValue = "hmmm.... its 51... what are you gonna do about that??";
break;
case 52:
returnValue = "lets not get sloppy now...";
break;
default:
returnValue = "nope, its definately something else";
break;
};
}
else
{
returnValue = "Thats not a number";
};
return returnValue;
}
}
static void Main(string[] args)
{
string num;
string result1;
do
{
Console.WriteLine("Guess what the value is, hint... its integer and between 1 and 100");
num = Console.ReadLine();
result1 = checkConvertValue(num);
Console.WriteLine(result1);
} while (result1 != "yep its 50");
Console.ReadLine();
}
}
}
誰かが私が間違っているところを教えてもらえますか?