Is it ok to use a class like this (design / guideline specific)? I\'m using MVVM Pattern.
public static class Pages
{
public const string Home = \"Home.xaml\
There are significant differences between const
and public static readonly
, and you should consider which to use with care:
(By "client" here, I mean "code in a different assembly referring to the member.)
const
. With public static readonly
, they will see the updated value. If you recompile all clients anyway, this isn't a problem.const
form is a compile time constant, which means it can be used in:
If you're happy to recompile all your clients if you ever change the value, the benefits of the second bullet point point towards using const
.
Of course, I wonder whether Pages
really needs to be public anyway... it sounds like something which could be internal
, with internal
members - at which point the downsides of const
go away entirely.