2
public void CreateMethod()
{
CodeMemberMethod mymethod = new CodeMemberMethod();
mymethod.Name = testMethod;
CodeTypeReference ctr = new CodeTypeReference();
//Assign the return type to the method.
mymethod.ReturnType = ctr;
CodeSnippetExpression snippet1 = new CodeSnippetExpression("AutomationBase obj = new AutomationBase()");
CodeSnippetExpression snippet2 = new CodeSnippetExpression("obj.Execute(testCases[1])");
CodeExpressionStatement stmt1 = new CodeExpressionStatement(snippet1);
CodeExpressionStatement stmt2 = new CodeExpressionStatement(snippet2);
mymethod.Statements.Add(stmt1);
mymethod.Statements.Add(stmt2);
mymethod.Attributes = MemberAttributes.Public;
myclass.Members.Add(mymethod);
}
public virtual void TestCaseId002() {
AutomationBase obj = new AutomationBase();
obj.Execute(testCases[1]);
}
得到虛擬無效
我只需要作廢。
'virtual'無關與返回類型。 –
由於'ctr。;'你提供的代碼甚至不會編譯。請提供一個[mcve](目前還不清楚這與ASP.NET有什麼關係,或者......) –
,但默認情況下c#方法是非虛擬的。 – Lijo