Question

I'm trying to figure out why this is not working...

public static class ApplicationType
{
    private static ApplicationEnum application = ApplicationEnum.App1; 
    public static ApplicationEnum Application
    {
        get { return application; }
        set { application = value; }
    }

    public enum ApplicationEnum
    {
        App1,
        App2,
        App3
    }
}

I want to access Application from another class, such as...

public partial class MainWindow : Window
{
    ApplicationType.   //<-- Intellisense shows only ApplicationEnum    }

Thanks.

EDIT: Problem was that I was not trying inside the MainWindow as in this example as I thought I was.

Was it helpful?

Solution

You're in the middle of a class declaration. You need to declare a field, method etc. For example, this should be fine (if you make ApplicationEnum public):

private ApplicationEnum foo = ApplicatoinType.Application;

Until you've made ApplicationEnum public, you'll find that your Application property will fail to compile - you can't declare a public property of a type which isn't itself public.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top