I have an application that, on occasion, might need to perform certain tasks on files, or other things that are "in-use" while the application in running.

This is what I've tried to do, but I'm running into problems:

I created an interface:

interface IShutdownCommand
        void OnShutdown();

I wanted to create, on my main application window code the following:

//initialize shutdown Commands
        public List<IShutdownCommand> ShutdownCommandList;

        private void Main_FormClosing(object sender, FormClosingEventArgs e)
                foreach (IShutdownCommand Command in ShutdownCommandList)

But I'm getting this compiler error:

"Inconsistent accessibility: field type 'System.Collections.Generic.List<DATA.IShutdownCommand>' is less accessible than field 'DATA.Main.ShutdownCommandList'"

Any thoughts on how I could do this and actually get it to work?

7 Years
Discussion Span
Last Post by zachattack05

Your interface is less accessible than your field. Put 'public' in front of the interface declaration.

What this is telling you is that you are trying to declare a publicly available variable (ShutdownCommandList) that uses something that isn't publicly available (IShutdownCommand).

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.