0
我有一個測試項目,它是一個庫。我想編寫一個控制檯應用程序,以便能夠引用測試項目的DLL並從我的測試項目中調用方法和類。C#針對測試項目的可執行項目(控制檯應用程序)
此外,在編寫控制檯應用程序時,我想要如何使用參數從命令提示符執行exe。我的控制檯應用程序代碼應該接受我提供並執行測試的輸入。
我只需要一些示例代碼,以便我可以從那裏拿起它。
我有一個測試項目,它是一個庫。我想編寫一個控制檯應用程序,以便能夠引用測試項目的DLL並從我的測試項目中調用方法和類。C#針對測試項目的可執行項目(控制檯應用程序)
此外,在編寫控制檯應用程序時,我想要如何使用參數從命令提示符執行exe。我的控制檯應用程序代碼應該接受我提供並執行測試的輸入。
我只需要一些示例代碼,以便我可以從那裏拿起它。
你必須遵循以下步驟:
usign myNamespaceOfMyDll;
樣品(使用GMmap的DLL):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GMap.NET;
usign myNamespace;
namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
//GPoint is a user data type declared in GMap.NET
//method is a method definied in myNamespace (your dll)
GPoint s=method(param1,param2);
}
}
}
假設你有一個代碼,你必須在你的主要方法中添加一個字符串數組作爲PARAM。
using System;
class Program
{
static void Main(string[] args)
{
if (args == null)
{
Console.WriteLine("args is null"); // Check for null array
}
else
{
//Here you can to use then content of your args array.
}
Console.ReadLine();
}
}
因此如果鍵入:
c:\> myApp param1 param2
ARGS [0] = 「參數1」,ARGS [1] = 「參數2」,並且陣列的長度是2。
謝謝你非常感謝萊昂內爾。你能回答這個問題的第二部分嗎? 「另外,在編寫控制檯應用程序時,我想要如何使用參數從命令提示符執行exe。我的控制檯應用程序代碼應該接受輸入並執行測試。」 – Sanmathi