C# Default values for getter-only propertiesThis feature allows us to set default values for the getters. The getter-only property is read-only property. We can't set a new value to this property. Compiler reports an error: cannot be assigned at compile time, if we assign value explicitly. C# Default value for getter-only property Example 1Output Rahul kumar [email protected] Let's see an example, what happen if we assign value explicitly. C# Default value for getter-only property Example 2Output error CS0200: Property or indexer 'Student.Name' cannot be assigned to -- it is read only Next TopicC# Expression Bodied Members |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India