Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a difference between "private readonly" and "readonly private"?

Tags:

c#

I was just reviewing some code and noticed someone had marked member as readonly private. Is this different from private readonly in any way?

Example:

readonly private MyClass myInstance = new MyClass();

I have never seen this before. I always use private then readonly. I could not find anything on MSDN (or even in the C# spec.) that mentions what order the access modifiers can appear in. Is there an article / reference somewhere?

like image 497
DaveShaw Avatar asked Nov 29 '22 02:11

DaveShaw


1 Answers

No, there is no difference. Another common time this happens is public static vs static public In either case, some people might argue it's more important to have the access modifier first, while others would argue it's more important the 'special' modifiers be seen.

But no, it doesn't make any difference at all and it's purely a style choice.

like image 137
K893824 Avatar answered Dec 05 '22 01:12

K893824