无法调用我的方法,我忘记了什么c#技能:新手
专注于其他任务后,重新投入工作 有人能告诉我为什么我会因此而出错吗无法调用我的方法,我忘记了什么c#技能:新手,c#,C#,专注于其他任务后,重新投入工作 有人能告诉我为什么我会因此而出错吗 static void Main(string[] args) { Console.WriteLine("% unique numbers"); Random rnd = new Random(); for (int count = 0; count <= 5; count++) { DiceR(); // ----
static void Main(string[] args)
{
Console.WriteLine("% unique numbers");
Random rnd = new Random();
for (int count = 0; count <= 5; count++)
{
DiceR(); // ------ Error here -----
}
}
public void DiceR()
{
Random rnd = new Random();
Console.WriteLine(rnd.Next(1, 6));
}
}
static void Main(字符串[]args)
{
Console.WriteLine(“%唯一编号”);
随机rnd=新随机();
对于(int count=0;count使其成为static
static public void DiceR()
{
Random rnd = new Random();
Console.WriteLine(rnd.Next(1, 6));
}
错误消息应该告诉您需要知道的内容-如果没有包含该方法的对象实例,则无法从静态方法调用实例(非静态)方法。您应该发布错误消息