不包含接受类型参数的defenition或extension方法

时间:2015-01-17 22:59:20

标签: c# .net debugging

我正在进行数据类型练习,当我尝试为数据类型类创建方法时,出现错误:

  

错误1' Data_Type_Explanations'不包含' RunExercize'的定义没有扩展方法' RunExercize'接受类型' Data_Type_Explanations'的第一个参数。可以找到(你是否缺少using指令或程序集引用?)\ data-types \ data-types \ Program.cs 39 17 PCE_01

这是我部分实施的代码:

主要:

Data_Type_Explanations dte = new Data_Type_Explanations();
            dte.RunExercize();

外:

class Data_Type_Explanations
{
    public void RunExercise()
    {

        sbyte x = 3; // stores from -128 to +127
        Console.WriteLine("Value of x is: " + x);
    }
}

我不理解错误消息。为什么它告诉该方法不在类中,而它在那里?

1 个答案:

答案 0 :(得分:1)

您的方法名称中有拼写错误。请在main中尝试以下代码:

Data_Type_Explanations dte = new Data_Type_Explanations();
dte.RunExercise();