HaBo
HaBo

Reputation: 14317

Access string property in multiple methods of C#.Net Console Application

How can i access a Property in Multiple methods of same class?

  class MainProgram
{
    List<string> logLines = new List<string>();
    private static void ParseTransmissionAction(string ActionChar)
    {
        logLines.Add(ActionChar);
    }
    private static void BeginProcessing(int i, string FileName)
    {
        logLines.Add(i + ")" + FileName + "...Processing...");
    }
    private static void CompletedParsingthisFile(string File, int Rows)
    {
        logLines.Add("Sucessfully Parsed \"" + File + "\" (" + Rows + ") Rows");
    }
}

Upvotes: 0

Views: 309

Answers (1)

Tejs
Tejs

Reputation: 41256

logLines in your program is not marked as static, and thus all your methods can't access it.

Change it to static or remove the static modifier on your methods.

Upvotes: 2

Related Questions