我需要从另一个 c# 应用程序运行控制台应用程序,如何从我的 c# 应用程序加载参数并将参数传递给控制台应用程序以执行控制台应用程序。 System.Diagnostics.ProcessStartInfo 有帮助吗?
最佳答案
使用 ProcessStartInfo 类
ProcessStartInfo p = new ProcessStartInfo();
p.Arguments = "your arguments";
p.FileName = "Application or Document Name";
Process.Start(p);
public IList<string> GetMatchingWords(string word)
{
var list = new List<string>();
int levelDepth = 0;
if (string.IsNullOrEmpty(word))
return list;
var tempWord = word[0];
var firstNode = RootNode.Childs.FirstOrDefault(x => x.Word[0].Equals(tempWord));
if (firstNode == null)
{
return list;
}
var nodePath = new Queue<TrieNode>();
var sb = new StringBuilder();
sb.Append(firstNode.Word);
while (firstNode != null)
{
levelDepth++;
if (levelDepth == word.Length)
{
break;
}
tempWord = word[levelDepth];
firstNode = firstNode.Childs.FirstOrDefault(x => x.Word[0].Equals(tempWord));
sb.Append(firstNode.Word);
}
if(firstNode!=null)
nodePath.Enqueue(firstNode);
originalValue = sb.ToString();
while (nodePath.Any())
{
var tempNode = nodePath.Dequeue();
tempNode.IsParentNode = true;
PopulateWords(tempNode, sb, ref list);
}
return list;
}
private void PopulateWords(TrieNode node,
StringBuilder sb,ref List<string> list)
{
if (node.Childs.Any())
{
foreach (var temp in node.Childs)
{
if (node.IsParentNode)
{
sb.Clear();
sb.Append(originalValue);
}
if (temp.Childs.Any())
{
sb.Append(temp.Word);
PopulateWords(temp, sb, ref list);
}
else
{
sb.Append(temp.Word);
list.Add(sb.ToString());
}
}
}
else
{
list.Add(sb.ToString());
}
}
关于c# - 从 C# 向控制台应用程序传递参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3985088/