user222427
user222427

Reputation:

Easist way to pass strings in a console app

I really wanted to just use

Class MyClasses
{

    public string mwaAHA = "here";
    //and then use it like this:

    static void testStringhere()
    {

        console.writeline(mwaAHA);

    }
}

I'm doing something wrong can someone demo the eaist way I can make a few strings and use them in any void?

Upvotes: 0

Views: 89

Answers (2)

David
David

Reputation: 2920

The answer above is right, but it should probably also have a private and a const..something like:

private const string str = "here";

Upvotes: 1

SirViver
SirViver

Reputation: 2441

Since your testStringhere() is static, it only has access to other static members residing in the same scope.

To solve your issue in this case use

public static string mwaAHA = "here";

Upvotes: 3

Related Questions