[.NET] Use collection expressions

As of C# 12 we can now use collection expressions to reduce some boilerplate when initializing collections.
This commit is contained in:
Raul Santos
2024-12-21 03:26:14 +01:00
parent 6d5fd9acc8
commit cea78730d0
14 changed files with 69 additions and 65 deletions

View File

@@ -220,7 +220,7 @@ So let's initialize an array of floats and create a storage buffer:
.. code-tab:: csharp
// Prepare our data. We use floats in the shader, so we need 32 bit.
var input = new float[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
float[] input = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
var inputBytes = new byte[input.Length * sizeof(float)];
Buffer.BlockCopy(input, 0, inputBytes, 0, inputBytes.Length);
@@ -251,7 +251,7 @@ assign it to a uniform set which we can pass to our shader later.
Binding = 0
};
uniform.AddId(buffer);
var uniformSet = rd.UniformSetCreate(new Array<RDUniform> { uniform }, shader, 0);
var uniformSet = rd.UniformSetCreate([uniform], shader, 0);
Defining a compute pipeline