【发布时间】:2015-06-09 11:36:45
【问题描述】:
当我尝试从另一个类(不是主类)调用方法时遇到一个小问题。这是我的测试代码:
using System;
namespace ConsoleApplication3
{
public class Program
{
static void Main(string[] args)
{
Class1 cl = new Class1();
cl.TestMethod();
}
}
public class Class1
{
public string TestMethod()
{
return "test";
}
}
public class Class2
{
Class1 cl = new Class1();
cl.TestMethod(); //Error here
}
}
在 Class2 中调用 TestMethod 应该怎么做?
【问题讨论】: