Why is DateTime.Now a property and not a method?

后端 未结 6 1282
眼角桃花
眼角桃花 2020-12-08 13:06

After reading this blog entry : http://wekeroad.com/post/4069048840/when-should-a-method-be-a-property,

I\'m wondering why Microsoft choose in C# :

D         


        
6条回答
  •  情深已故
    2020-12-08 13:50

    Since there are no brightline rules on when to use a method and a property, DateTime.Now is truly just reading an exposed property of the state of the server, it may be constantly changing, but DateTime.Now never effects the state of any property, object or what not, so it is a property in the Framework.

提交回复
热议问题