Properties in C sharp Arabic II #26

 



Properties in C sharp Arabic II #26


Suggested Videos

Properties in C sharp Arabic I #25

❑ Read/write Properties.

❑ Read Only properties.

❑ Write only properties.

❑ Auto implemented properties.



Properties

in C# encapsulate and protect fields we use properties.

❑ We use get and set accessors to implement properties .

❑ A property with both get and set is a Read/write property.

❑ A property with only get accessor is a Read only property. 

❑ A property with only set accessor is a Write only property.

Note: the advantage of properties over traditional Get() and Set() methods is that ,you can access them as if they were public fields.




Auto Implemented properties 


❑ If there is no additional logic in the property accessors, the we can make use of autoImplemented properties introduced in C# 3.0.

❑ Auto-implemented properties reduce the amount of code that we have to write .

❑ When you use auto-implemented properties, the compiler creates a private , anonymous field that can only be accessed through the property’s get and set accessors

Follow Us

YouTube

 If you want to download pptx : click Telegram

Facebook

Twitter

Instagram

Tik Tok


إرسال تعليق

أحدث أقدم