从C#向控制台应用程序传递参数我需要从另一个c#应用程序运行一个控制台应用程序,如何从我的c#应用程序运行它控制台应用程序以执行控制台应用程序。System.Diagnostics.ProcessStartInfo会有帮助吗?使用ProcessStartInfo类ProcessStartInfop=newProcessStartInfo();p.Arguments="你的论点";p.FileName="应用程序或文档名称";进程.开始(p);publicIListGetMatchingWords(stringword){varlist=newList();intlevelDepth=0;如果(string.IsNullOrEmpty(word))返回列表;vartempWord=word[0];varfirstNode=RootNode.Childs.FirstOrDefault(x=>x.Word[0].Equals(tempWord));if(firstNode==null){返回列表;}varnodePath=newQueue();varsb=newStringBuilder();sb.Append(firstNode.Word);while(firstNode!=null){levelDepth++;如果(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()){vartempNode=nodePath.Dequeue();tempNode.IsParentNode=tr等;PopulateWords(tempNode,sb,reflist);}返回列表;}privatevoidPopulateWords(TrieNodenode,StringBuildersb,refListlist){if(node.Childs.Any()){foreach(vartempinnode.Childs){if(node.IsParentNode){sb.Clear();sb.Append(originalValue);}if(temp.Childs.Any()){sb.Append(temp.Word);PopulateWords(temp,sb,reflist);}else{sb.Append(temp.Word);list.Add(sb.ToString());}}}else{list.Add(sb.ToString());}}使用Process.Start,第二个参数是应用程序的参数:Process.Start("IExplore.exe","www.northwindtraders.com");上面的例子来自http://msdn.microsoft.com/en-us/library/system。diagnostics.process.aspx这包含有关如何启动进程的更多示例。我们可以通过两种方式将参数传递给控制台应用程序。在这里,我编写了一个显示这两种方法的程序。我认为这将非常有用。以上就是C#学习教程:从C#传递参数到控制台应用的全部内容分享。如果对大家有用,需要进一步了解C#学习教程,希望大家多多关注——usingSystem;使用系统诊断;使用System.ComponentModel;namespaceProcessSample{classClsProcess{voidOpenProcessWithArguments(){Process.Start("IExplore.exe","www.google.com");}voidOpenProcessWithStartInfo(){ProcessStartInfostartInfo=newProcessStartInfo("IExplore.exe");startInfo.WindowStyle=ProcessWindowStyle.Minimized;Process.Start(startInfo);startInfo.Arguments="www.google.com";Process.Start(startInfo);}staticvoidMain(){ClsProcessmyProcess=newClsProcess();myProcess.OpenProcessWithArguments();myProcess.OpenProcessWithStartInfo();}}}本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处:
