Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

public static vs static public - is there a difference?

Tags:

c#

.net

sealed class PI
{
  public static float number;
  static PI()
  { number = 3.141592653F; }
  static public float val()
  { return number; }
}
  1. What's the difference between public static and static public? Can they be used in any order?

  2. How would I use static public float val()?

    Does it get executed as soon as the class is initialized?

like image 579
Alex Gordon Avatar asked Nov 10 '10 18:11

Alex Gordon


2 Answers

There's no difference. You're free to specify them in either order. However, I find that most developers tend to use public static and not static public.

like image 136
Jesper Larsen-Ledet Avatar answered Oct 20 '22 01:10

Jesper Larsen-Ledet


Well, it is just like the name of a Person =) Calling Tom Mike or Mike Tom, no difference.

like image 35
Singleton Avatar answered Oct 19 '22 23:10

Singleton