Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Settings File: Why do I have to use Settings.Default?

I'm just wondering why it's Settings.Default.<mysetting> instead of just Settings.<mysetting>?

like image 594
michael Avatar asked Jan 10 '11 13:01

michael


1 Answers

Simply put: because Settings is a class, and the properties are instance properties. So you need an instance, and the default way of creating an instance is through the Default property.

The obvious followup question is why the properties aren't just static to start with... and I surmise that the answer is that it's useful to be able to create settings in ways other than with the default settings load/save approach... for example, loading them from a database, or from a different file path.

like image 147
Jon Skeet Avatar answered Oct 04 '22 20:10

Jon Skeet