?
- . , get, . , , set . , , .
I, 12.6.6 CLI : " CLI , , , , ."
, . , , - :
Private T _item;
public T Item
{
get
{
return _item;
}
set
{
_item = value
}
}
An example is if you want to stick to common material and use it for everything. The approach is to use a helper class-media. This significantly reduces performance, but is not blocked.
Public Foo
{
Private Carrier<T>
{
T _item
}
Private Carrier<T> _item;
public T Item
{
get
{
Dim Carrier<T> carrier = _item;
return carrier.item;
}
set
{
Dim Carrier<T> carrier = new Carrier<T>();
carrier.item = value;
_item = carrier;
}
}
}
This way you can ensure that you always use reference types and that your access is blocked. The disadvantage is that all given operations create garbage.
source
share