.net - Method Vs Property -
I am a newbie for .NET. I have a class named Project, many projects can be predicted in a project.Now if I want to see if there are any predictions in the projects or not, then I should use Boolean property to read (HasForecast) or I should use a method called HasForecast () to basically give a boolean value. From the framework design guidelines I came to know that methods should be used when the operation is complex, because here I am recovering the value of the forecast from DB, I should consider the method, or because it is a logical data member, The property should be used. If I can use any asset, I can call a method in my DBAir from my planet. Please,
Please, Ravi
attribute should be very light weight which works If you need access to a database then you should use one method.
See MSDN here:
Properties vs. Ways
Class library designers often have to decide between applying a class member as an asset or method Generally, methods represent the actions and represent the data to the properties. Use the following guidelines to choose between these options.
Use a property When a member is a logical data member, in the following member declarations, the name is a property because it is a logical member of the class. Use a method when:
Comments
Post a Comment