So, in class I am almost done with the C# tutorials and I am at the last section. In the section before, there was a tutorial on properties. Properties come up in many of the tutorials, so I wanted to fully understand how and when to use them. Properties are a very important aspect of code and I wanted more clarification on them.
I found a couple articles on properties called Properties (C# Programming Guide), which gave some insight to properties and also had sub articles on specific parts. I learned that properties can be one of three kinds: write-only, read-write, read-only. Read-only have only the get accessor, while read-white has both the get and set accessor. Write-only has only the set accessor. Get and set property accessors have different uses. Set property accessors are used for assigning values, while get property accessors are for returning the property value. Each property has different accessibility levels. Auto-implemented properties are properties that can be implemented without a accessor code. Properties are a way to set and get values while not showing verification code. I learned that when you want to define a value that being assigned using the set accessor, you use the keyword value. I wanted to know more specifically on how to use properties so I clicked on one of the sub articles that was on using properties called Using Properties (C# Programming Guide). I learned that properties are a combination on methods and fields. You can do many things with properties: changing values of fields, validate data, figure out if data is from other sources, and do things when data has been changed. To declare a property, you have to specifying the access, then put the type and the name, then put a code block with either a set or get accessor. There are many access modifiers that property can have. They can be private, public, protected, internal, private protected, or protected internal. Properties can also be declared abstract, static, or virtual. Points about Properties:
“Properties (C# Programming Guide).” Microsoft Docs, docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties. “Using Properties (C# Programming Guide).” Microsoft Docs, docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/using-properties.
0 Comments
Leave a Reply. |
AuthorI'm a student at Durham School of the Arts, and currently in the Game Art Design pathway. I like playing the Sims 4, playing with dogs, and riding horses. This blog will reflect my learning and discoveries. Archives
May 2019
Categories
All
|