Chain properties in C # and unexpected results

I just quickly read this article (in particular, a little about why he decided to use structs / fields instead of classes / properties) and saw this line:

The result of the property is not the true value of l, so we cannot do something like Vertex.Normal.dx = 0. The property chain gives very unexpected results.

What unexpected results is he talking about?

+2
source share
2 answers

I would add to dbemerlin the answer that the key here is Rico, that the properties are not “lvalues”, or, as we call them in C #, “variables”.

(, , : , ), . - , . vector,

Foo.vector.x = 123;

- Foo.vector - x. :

Foo.vector.x = 123;

.

Vector v = Foo.Vector;
v.x = 123;

v, , .

, . x, :

Foo.Vector = new Vector(x, Foo.Vector.y);
+5

"" , , Vertex.Normal , 0 dx .

, , ( , .NET )

+2

Source: https://habr.com/ru/post/1730381/


All Articles