书上的例子也编译不过,有没有高手能帮该过来啊???(一个c#的例子)
我的这段程序编译出错,不知道错在那里,我是新手,请那位高人帮小弟一把,多谢!
using System;
public class TestMethod
{
static int x;
int y;
public static void MethodA()
{
x=10;
//y=20;
Console.WriteLine("In MethodA");
}
public void MethodB()
{
x=10;
y=20;
Console.WriteLine("In MethodB");
}
}
class ClassTest
{
static void Main(string[] args)
{
TestMethod t1 = new TestMothod();
t1.MethodB();
TestMethod.MethodA();
}
}
错误信息如下:
Microsoft (R) Visual C# .NET Compiler version 7.00.9951
ClassTest.cs(27,29): error CS0246:
找不到类型或命名空间名称“TestMothod”(是否缺少 using
指令或程序集引用?)
问题点数:20、回复次数:6Top
1 楼sqlchen(哈欠)回复于 2005-12-08 15:08:44 得分 20
大哥拼错了
TestMothod <=> TestMethod
Top
2 楼RxitRose(天恒)回复于 2005-12-08 15:09:30 得分 0
using System;
namespace TestSpace
{
public class TestMethod
{
static int x;
int y;
public static void MethodA()
{
x=10;
//y=20;
Console.WriteLine("In MethodA");
}
public void MethodB()
{
x=10;
y=20;
Console.WriteLine("In MethodB");
}
}
class ClassTest
{
static void Main(string[] args)
{
TestMethod t1 = new TestMothod();
t1.MethodB();
TestMethod.MethodA();
}
}
}
這樣就可以了
Top
3 楼sqlchen(哈欠)回复于 2005-12-08 15:09:35 得分 0
大哥拼错了
TestMothod <=> TestMethodTop
4 楼RxitRose(天恒)回复于 2005-12-08 15:11:26 得分 0
using System;
namespace TestSpace
{
public class TestMethod
{
static int x;
int y;
public static void MethodA()
{
x=10;
//y=20;
Console.WriteLine("In MethodA");
}
public void MethodB()
{
x=10;
y=20;
Console.WriteLine("In MethodB");
}
}
class ClassTest
{
static void Main(string[] args)
{
TestMethod t1 = new TestMethod();
t1.MethodB();
TestMethod.MethodA();
}
}
}
這樣就可以了
Top
5 楼435002(啸鸣2008)回复于 2005-12-08 15:19:14 得分 0
不好意思了,多谢!Top
6 楼jxufewbt(我的目标是5星)回复于 2005-12-08 15:19:37 得分 0
TestMothod
---->
TestMethodTop




