Proposal: A compact Full ReadOnly Property
- Dominant language
- No language data
- Stars
- 328
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
Proposal: A compact Full ReadOnly Property
Every time I get confused about the meaning of assigning an expression to auto implemented read-only property in VB: is it just an initial value that is only executed once, or will it be executed every time the property is called?!
`Public ReadOnly Property Content() as String = Foo()`
This is becfuase C# has = and => that makes the difference between the two meaning very cler!
So, I decide to write the full property:
```VB.NET
Public ReadOnly Property Content() string
Get
Return Foo()
End Get
End Property
```
I cal recall that there are proposals to add => to VB, but today, I have another suggestion: just get rid of `Get… end Get`:
```VB.NET
Public ReadOnly Property Content() string
Return Foo()
End Property
```
This shorter syntax has every info that has to tell and still in a VB style (without =>)!
And it can be perfect with a multiline body:
```VB.NET
Public ReadOnly Property Sum() string
Dim _sum = 0
For each .....
_sum+= .......
Next
Return _sum
End Property
```
Likewise, and just for duality, the write-only property (which I never used) can get rid of the `Set End Set` and use the Value param directly (as it can be earased from Set End Set today and still be used)
```VB.NET
dim _whatEver as string
Public WriteOnly Property WhatEver() As string
_whatEver = Value
End Property
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.