Hello lid6j86.
This behaviour is a result of a somewhat poor design choice, of not implementing all structs as immutables in the .net bindings version of SFML. You want to only allow setting field values of value types during construction, either via using a parameterized constructor, or the initialization syntax, e.g.
var vertex
= new Vertex
{ Position
= new Vector2f
(50,
50) }; It was correctly done with for example the operator overloads of Vertex2f, but not its fields. As a result, people will call the implicit default constructor and forget to assign values to some of the fields.
In your example, when you created a new Vertex using the default (non explicit) constructor, the color was intialized with rgba values (0, 0, 0, 0).
vArray
[0].Position = new Vector2f
(0,
0);vArray
[0].TexCoords = new Vector2f
(0,
0);vArray
[0].Color = new Color
(255,
255,
255,
255); //fineIf all value types would have only read only fields, you would not be able forget to set any of its fields, so it is intialized with the default value of the type of the field. (Or, if you use the initialization syntax with curly brackets, your IDE will probably display all fields and you will not forget to assign a value to the color )