簡體   English   中英

C# CodeDom Double Type 參考

[英]C# CodeDom Double Type Reference

我可以通過使用CodeMethodInvokeExpressionCodeTypeReferenceExpression來調用某種類型,但我希望能夠引用以下代碼行:

Process p = new Process();
p.StartInfo.FileName = "FilePath";

這是我到目前為止所得到的-

CodeVariableDeclarationStatement statement = new CodeVariableDeclarationStatement(typeof(System.Diagnostics.Process), "p",
    new CodeObjectCreateExpression("System.Diagnostics.Process",
    new CodeExpression[] { }));

我無法弄清楚如何為我的一生生成“p.StartInfo.FileName = exFilePath”行。

任何有關此事的幫助將不勝感激!

謝謝你,埃文

就像是

new CodeAssignStatement(
    new CodePropertyReferenceExpression(
        new CodePropertyReferenceExpression(
              new CodeVariableReferenceExpression("p"),
              "StartInfo"),
        "FileName"),
    new CodePrimitiveExpression("FilePath"))

應該做。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM