关于如何实现此字符串容器方法的建议

时间:2015-10-20 21:23:35

标签: c# python string wrapper

我有两个应用程序c#和python,我需要从C#向python发送参数。我现在实施它的方式是。

string myString = "";
myString += "print(\"This is my string of text\")";
myString += "secondLine = \"This is another for readability\"";
myString += "print(secondLine)"
//Then I have to send it out
SendMessage(myString);

您会建议更好的方法来实现这一目标吗?我想到了类似的东西:

      static string tempMessage = "";

      private static void SProc(string sArg = "")
       {
          if (sArg == "")
          {
              SendMessage(tempMessage);
              tempaMessage = "";
          }
           else
             tempMessage += sArg;
          }
        }

     //Sends a message to the string
     SProc("Foo");
     //Calls method with the containing string.
     SProc();

有没有更清洁的方法可以建议您这样做?

谢谢你们,

0 个答案:

没有答案