Is there a difference between readonly private and readonly private?

I was just looking at the code and noticed that someone marked the element as readonly private . Is this different from private readonly any way?

Example:

 readonly private MyClass myInstance = new MyClass(); 

I've never seen this before. I always use private , then readonly . I could not find anything in the MSDN (or even in the C # specification) that mentions in which order access modifiers may appear. Is there an article / link somewhere?

+4
source share
4 answers

No, there is no difference. Another common time is public static vs static public In any case, some people may argue that it is more important to have an access modifier in the first place, while others will argue that it is more important that special modifiers are visible.

But no, it does not matter at all, and it is purely a style choice.

+12
source

This does not matter for the compiler, but it (maybe) matters for the code browser or the next person to work on this code.

As the others answered, the order does not matter. You must be consistent in your order of these keywords. I usually place the area first ( public / private ) and then the behavior ( readonly / abstract / static ).

Choose an order that works for you and your team and stick to it.

Good luck

+5
source

No, there is no difference. These keywords are just modifiers; their order is not important.

+4
source

There is no difference. Both are the same.
See this question .

+3
source

All Articles