I was just thinking about it, and since .NET introduced the properties, there is always a situation where you want to leave your code as a method that returns a value, not a readonly property.
No. I would recommend taking a look at the Microsoft Property Usage Guides :
Class library designers often need to decide between implementing a class member as a property or method. In general, methods represent actions and properties represent data. Use the following guidelines to help you choose between these options., . , ., :- , Object.ToString., .get accessor ... , ., , .. , , . , . , , , , . , . 2n + 1 .
Class library designers often need to decide between implementing a class member as a property or method. In general, methods represent actions and properties represent data. Use the following guidelines to help you choose between these options.
, , . , .
, , , . , . this, "" API. .
this
, .
. , - , , .
, , .
, , , . , , - . , , - :
foreach( var x in myClass.PropertyThatReturnsArray ) { }
. , , , , :
var foo = myClass.GetTheArray(); foreach( var x in foo ) { }
( , fxcop: http://msdn.microsoft.com/en-us/library/0fss9skc(VS.80).aspx).
.:)
Source: https://habr.com/ru/post/1746199/More articles:Linq 'index was outside array problem - c #What is wrong with this SQL statement - sqlParallel programming, don't we learn from history again? - designC # Looping the process and until the user presses the key - c #Accessing Helper Functions / Procedures from DPR or Other Functions / Procedures in Delphi - subroutinehttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1746200/mock-repository-vs-real-repository-wmocked-data&usg=ALkJrhgBNB5Tdn17z7liUvwcEZImQkVqsAHow to determine the order data read from the MYSQL database? - mysqlКто-нибудь еще предпочитает архитектуру N-уровня после того, как * отправил * приложение MVC? - language-agnosticHow to use cscope in visual studio? - visual-studio-2008Нужен простой совет для решения проблемы графа - algorithmAll Articles