I came across a recent audit report in our company for the code that we support, which says that we should not use Get in a method (not a property) called GetSearchResults or GetXyzInformation. I looked at MS Recommendations ( http://msdn.microsoft.com/en-us/library/4df752aw(VS.71).aspx ) for the name of the method and according to the fact that Get is allowed, so what you think about it, can we have it or not from a standard point of view, if not why?
Additional informationI am adding more information after the first set of answers, the methods that I have in mind are the kind that is associated with interacting with the database, so the properties of the properties are not ideal.
This is completely legal (itβs even legal to write get_Foo form methods that will encounter a synthesized compiler get method if you have to declare a Foo property using getter).
As for the good :
, , , "", "", , , . p >
, , , - API (, Delegate.GetInvocationList).
, , , GetFoo.
, , , ( ).
:
, " ", :
public string TextWriter { get {...} set {...}} public string GetTextWriter(int value) {...}
Get-method , , .
, SearchResults { get; }
SearchResults { get; }
, , VB.NET:
ReadOnly Property Foo(ByVal i As Integer, ByVal j As Integer) As String Get Return "" End Get End Property
, IL GetFoo(int, int), VB.NET - !
GetFoo(int, int)
, GetXyz, , ( , Xyz).
GetXyz
Xyz
GetXyz FindXyz , null . , , , find null, .
FindXyz
null
Get . , :
Get:
public string GetSomeString() { return _someMemberVariable; }
: , , , Get , .
.
public string GetSomeString() { //Some code that does processing or includes logic. }
, " " ( , ).
- , / , , . - , , , - , , Get.
, - , - .
Get , .
Source: https://habr.com/ru/post/1703732/More articles:DataGridView - displaying the value of an object in a column - c #https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1703728/how-can-i-rewrite-all-but-my-ip-address-to-the-std-apache-503-temporarily-down-error-message&usg=ALkJrhiuDOKIbPgaTHRDPmMULb8iPIo9ZAHow to make surround svn mv on Unix - svnVectors, iterators, and std :: find - c ++SharePoint Webpart Deserialization Error - serializationIs there a free open source JavaScript-to-JavaScript compiler (like Google)? - optimizationGD2 and PHP on OS X - phpHow many of you record your historical project data for future evaluations and how do you do it? - project-managementIn Python, how do I create a temporary file that persists until the next run? - pythonHow to ensure the minimum width of a formatted string in C # - stringAll Articles