开发者

C# Creating and passing strings between voids Console Application

This is what I have

public static string allRecords开发者_运维问答Found = "";

static void parseRecords()
{

// do all my work here
allRecordsFound = "sadsda"; //this is whats this static void creats  
}

static void doMoreWork()
{
string[] splitRecords = allRecordsFound.Split('\n');

}

I'm just not positive how to reset the public static string so after the void that finds the data can pass it throughout the whole Console app.

Thanks!


First option would be adding a parameter to doMoreWork() so it will become doMoreWork(string records).

If you insist using static variables for passing parameters or the application is multi-threaded then you can use a Queue instead. First method puts records into queue and second one gets them. If there are more than one thread acessing the queue then use ConcurrentQueue which is available in .NET 4.0

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜