[.NET] Use collection expressions in docs

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 02:28:59 +01:00
parent 89001f91d2
commit 072ff85f82
No known key found for this signature in database
GPG key ID: B532473AE3A803E4
17 changed files with 73 additions and 73 deletions

View file

@ -853,7 +853,7 @@
print("a", "b", a) # Prints ab[1, 2, 3] print("a", "b", a) # Prints ab[1, 2, 3]
[/gdscript] [/gdscript]
[csharp] [csharp]
var a = new Godot.Collections.Array { 1, 2, 3 }; Godot.Collections.Array a = [1, 2, 3];
GD.Print("a", "b", a); // Prints ab[1, 2, 3] GD.Print("a", "b", a); // Prints ab[1, 2, 3]
[/csharp] [/csharp]
[/codeblocks] [/codeblocks]

View file

@ -17,14 +17,14 @@
print(array[-3]) # Prints "Second" print(array[-3]) # Prints "Second"
[/gdscript] [/gdscript]
[csharp] [csharp]
var array = new Godot.Collections.Array{"First", 2, 3, "Last"}; Godot.Collections.Array array = ["First", 2, 3, "Last"];
GD.Print(array[0]); // Prints "First" GD.Print(array[0]); // Prints "First"
GD.Print(array[2]); // Prints 3 GD.Print(array[2]); // Prints 3
GD.Print(array[array.Count - 1]); // Prints "Last" GD.Print(array[^1]); // Prints "Last"
array[2] = "Second"; array[1] = "Second";
GD.Print(array[1]); // Prints "Second" GD.Print(array[1]); // Prints "Second"
GD.Print(array[array.Count - 3]); // Prints "Second" GD.Print(array[^3]); // Prints "Second"
[/csharp] [/csharp]
[/codeblocks] [/codeblocks]
[b]Note:[/b] Arrays are always passed by [b]reference[/b]. To get a copy of an array that can be modified independently of the original array, use [method duplicate]. [b]Note:[/b] Arrays are always passed by [b]reference[/b]. To get a copy of an array that can be modified independently of the original array, use [method duplicate].
@ -358,7 +358,7 @@
print(array) # Prints [2, 2, 2, 2, 2] print(array) # Prints [2, 2, 2, 2, 2]
[/gdscript] [/gdscript]
[csharp] [csharp]
var array = new Godot.Collections.Array(); Godot.Collections.Array array = [];
array.Resize(5); array.Resize(5);
array.Fill(2); array.Fill(2);
GD.Print(array); // Prints [2, 2, 2, 2, 2] GD.Print(array); // Prints [2, 2, 2, 2, 2]
@ -460,7 +460,7 @@
print(["inside", 7].has("7")) # Prints false print(["inside", 7].has("7")) # Prints false
[/gdscript] [/gdscript]
[csharp] [csharp]
var arr = new Godot.Collections.Array { "inside", 7 }; Godot.Collections.Array arr = ["inside", 7];
// By C# convention, this method is renamed to `Contains`. // By C# convention, this method is renamed to `Contains`.
GD.Print(arr.Contains("inside")); // Prints True GD.Print(arr.Contains("inside")); // Prints True
GD.Print(arr.Contains("outside")); // Prints False GD.Print(arr.Contains("outside")); // Prints False
@ -573,7 +573,7 @@
print([1, 2, 3.25, "Hi"].pick_random()) print([1, 2, 3.25, "Hi"].pick_random())
[/gdscript] [/gdscript]
[csharp] [csharp]
var array = new Godot.Collections.Array { 1, 2, 3.25f, "Hi" }; Godot.Collections.Array array = [1, 2, 3.25f, "Hi"];
GD.Print(array.PickRandom()); // May print 1, 2, 3.25, or "Hi". GD.Print(array.PickRandom()); // May print 1, 2, 3.25, or "Hi".
[/csharp] [/csharp]
[/codeblocks] [/codeblocks]
@ -755,7 +755,7 @@
print(numbers) # Prints [2.5, 5, 8, 10] print(numbers) # Prints [2.5, 5, 8, 10]
[/gdscript] [/gdscript]
[csharp] [csharp]
var numbers = new Godot.Collections.Array { 10, 5, 2.5, 8 }; Godot.Collections.Array numbers = [10, 5, 2.5, 8];
numbers.Sort(); numbers.Sort();
GD.Print(numbers); // Prints [2.5, 5, 8, 10] GD.Print(numbers); // Prints [2.5, 5, 8, 10]
[/csharp] [/csharp]
@ -817,8 +817,8 @@
[/gdscript] [/gdscript]
[csharp] [csharp]
// Note that concatenation is not possible with C#'s native Array type. // Note that concatenation is not possible with C#'s native Array type.
var array1 = new Godot.Collections.Array{"One", 2}; Godot.Collections.Array array1 = ["One", 2];
var array2 = new Godot.Collections.Array{3, "Four"}; Godot.Collections.Array array2 = [3, "Four"];
GD.Print(array1 + array2); // Prints ["One", 2, 3, "Four"] GD.Print(array1 + array2); // Prints ["One", 2, 3, "Four"]
[/csharp] [/csharp]
[/codeblocks] [/codeblocks]

View file

@ -25,16 +25,16 @@
m.mesh = arr_mesh m.mesh = arr_mesh
[/gdscript] [/gdscript]
[csharp] [csharp]
var vertices = new Vector3[] Vector3[] vertices =
{ [
new Vector3(0, 1, 0), new Vector3(0, 1, 0),
new Vector3(1, 0, 0), new Vector3(1, 0, 0),
new Vector3(0, 0, 1), new Vector3(0, 0, 1),
}; ];
// Initialize the ArrayMesh. // Initialize the ArrayMesh.
var arrMesh = new ArrayMesh(); var arrMesh = new ArrayMesh();
var arrays = new Godot.Collections.Array(); Godot.Collections.Array arrays = [];
arrays.Resize((int)Mesh.ArrayType.Max); arrays.Resize((int)Mesh.ArrayType.Max);
arrays[(int)Mesh.ArrayType.Vertex] = vertices; arrays[(int)Mesh.ArrayType.Vertex] = vertices;

View file

@ -19,7 +19,7 @@
server.listen(4242) server.listen(4242)
var key = load("key.key") # Your private key. var key = load("key.key") # Your private key.
var cert = load("cert.crt") # Your X509 certificate. var cert = load("cert.crt") # Your X509 certificate.
dtls.setup(key, cert) dtls.setup(TlsOptions.server(key, cert))
func _process(delta): func _process(delta):
while server.is_connection_available(): while server.is_connection_available():
@ -45,19 +45,19 @@
{ {
private DtlsServer _dtls = new DtlsServer(); private DtlsServer _dtls = new DtlsServer();
private UdpServer _server = new UdpServer(); private UdpServer _server = new UdpServer();
private Godot.Collections.Array<PacketPeerDtls> _peers = new Godot.Collections.Array<PacketPeerDtls>(); private Godot.Collections.Array<PacketPeerDtls> _peers = [];
public override void _Ready() public override void _Ready()
{ {
_server.Listen(4242); _server.Listen(4242);
var key = GD.Load<CryptoKey>("key.key"); // Your private key. var key = GD.Load<CryptoKey>("key.key"); // Your private key.
var cert = GD.Load<X509Certificate>("cert.crt"); // Your X509 certificate. var cert = GD.Load<X509Certificate>("cert.crt"); // Your X509 certificate.
_dtls.Setup(key, cert); _dtls.Setup(TlsOptions.Server(key, cert));
} }
public override void _Process(double delta) public override void _Process(double delta)
{ {
while (Server.IsConnectionAvailable()) while (_server.IsConnectionAvailable())
{ {
PacketPeerUdp peer = _server.TakeConnection(); PacketPeerUdp peer = _server.TakeConnection();
PacketPeerDtls dtlsPeer = _dtls.TakeConnection(peer); PacketPeerDtls dtlsPeer = _dtls.TakeConnection(peer);

View file

@ -1730,7 +1730,7 @@
DisplayServer.WindowSetMousePassthrough(GetNode<Polygon2D>("Polygon2D").Polygon); DisplayServer.WindowSetMousePassthrough(GetNode<Polygon2D>("Polygon2D").Polygon);
// Reset region to default. // Reset region to default.
DisplayServer.WindowSetMousePassthrough(new Vector2[] {}); DisplayServer.WindowSetMousePassthrough([]);
[/csharp] [/csharp]
[/codeblocks] [/codeblocks]
[b]Note:[/b] On Windows, the portion of a window that lies outside the region is not drawn, while on Linux (X11) and macOS it is. [b]Note:[/b] On Windows, the portion of a window that lies outside the region is not drawn, while on Linux (X11) and macOS it is.

View file

@ -63,7 +63,7 @@
public override string[] _GetRecognizedExtensions() public override string[] _GetRecognizedExtensions()
{ {
return new string[] { "special", "spec" }; return ["special", "spec"];
} }
public override string _GetSaveExtension() public override string _GetSaveExtension()
@ -88,14 +88,14 @@
public override Godot.Collections.Array<Godot.Collections.Dictionary> _GetImportOptions(string path, int presetIndex) public override Godot.Collections.Array<Godot.Collections.Dictionary> _GetImportOptions(string path, int presetIndex)
{ {
return new Godot.Collections.Array<Godot.Collections.Dictionary> return
{ [
new Godot.Collections.Dictionary new Godot.Collections.Dictionary
{ {
{ "name", "myOption" }, { "name", "myOption" },
{ "default_value", false }, { "default_value", false },
} },
}; ];
} }
public override Error _Import(string sourceFile, string savePath, Godot.Collections.Dictionary options, Godot.Collections.Array<string> platformVariants, Godot.Collections.Array<string> genFiles) public override Error _Import(string sourceFile, string savePath, Godot.Collections.Dictionary options, Godot.Collections.Array<string> platformVariants, Godot.Collections.Array<string> genFiles)

View file

@ -45,7 +45,7 @@
public override string[] _GetRecognizedExtensions() public override string[] _GetRecognizedExtensions()
{ {
return new string[] { "csv" }; return ["csv"];
} }
} }
[/csharp] [/csharp]
@ -62,11 +62,11 @@
[/gdscript] [/gdscript]
[csharp] [csharp]
// This will add a message with msgid "Test 1", msgctxt "context", and msgid_plural "test 1 plurals". // This will add a message with msgid "Test 1", msgctxt "context", and msgid_plural "test 1 plurals".
msgidsContextPlural.Add(new Godot.Collections.Array{"Test 1", "context", "test 1 Plurals"}); msgidsContextPlural.Add(["Test 1", "context", "test 1 Plurals"]);
// This will add a message with msgid "A test without context" and msgid_plural "plurals". // This will add a message with msgid "A test without context" and msgid_plural "plurals".
msgidsContextPlural.Add(new Godot.Collections.Array{"A test without context", "", "plurals"}); msgidsContextPlural.Add(["A test without context", "", "plurals"]);
// This will add a message with msgid "Only with context" and msgctxt "a friendly context". // This will add a message with msgid "Only with context" and msgctxt "a friendly context".
msgidsContextPlural.Add(new Godot.Collections.Array{"Only with context", "a friendly context", ""}); msgidsContextPlural.Add(["Only with context", "a friendly context", ""]);
[/csharp] [/csharp]
[/codeblocks] [/codeblocks]
[b]Note:[/b] If you override parsing logic for standard script types (GDScript, C#, etc.), it would be better to load the [code]path[/code] argument using [method ResourceLoader.load]. This is because built-in scripts are loaded as [Resource] type, not [FileAccess] type. For example: [b]Note:[/b] If you override parsing logic for standard script types (GDScript, C#, etc.), it would be better to load the [code]path[/code] argument using [method ResourceLoader.load]. This is because built-in scripts are loaded as [Resource] type, not [FileAccess] type. For example:
@ -90,7 +90,7 @@
public override string[] _GetRecognizedExtensions() public override string[] _GetRecognizedExtensions()
{ {
return new string[] { "gd" }; return ["gd"];
} }
[/csharp] [/csharp]
[/codeblocks] [/codeblocks]

View file

@ -204,7 +204,7 @@
print(polygon) # Prints [(50.0, 50.0), (150.0, 50.0), (150.0, 150.0), (50.0, 150.0)] print(polygon) # Prints [(50.0, 50.0), (150.0, 50.0), (150.0, 150.0), (50.0, 150.0)]
[/gdscript] [/gdscript]
[csharp] [csharp]
var polygon = new Vector2[] { new Vector2(0, 0), new Vector2(100, 0), new Vector2(100, 100), new Vector2(0, 100) }; Vector2[] polygon = [new Vector2(0, 0), new Vector2(100, 0), new Vector2(100, 100), new Vector2(0, 100)];
var offset = new Vector2(50, 50); var offset = new Vector2(50, 50);
polygon = new Transform2D(0, offset) * polygon; polygon = new Transform2D(0, offset) * polygon;
GD.Print((Variant)polygon); // Prints [(50, 50), (150, 50), (150, 150), (50, 150)] GD.Print((Variant)polygon); // Prints [(50, 50), (150, 50), (150, 150), (50, 150)]

View file

@ -156,7 +156,7 @@
[csharp] [csharp]
var fields = new Godot.Collections.Dictionary { { "username", "user" }, { "password", "pass" } }; var fields = new Godot.Collections.Dictionary { { "username", "user" }, { "password", "pass" } };
string queryString = new HttpClient().QueryStringFromDict(fields); string queryString = new HttpClient().QueryStringFromDict(fields);
string[] headers = { "Content-Type: application/x-www-form-urlencoded", $"Content-Length: {queryString.Length}" }; string[] headers = ["Content-Type: application/x-www-form-urlencoded", $"Content-Length: {queryString.Length}"];
var result = new HttpClient().Request(HttpClient.Method.Post, "index.php", headers, queryString); var result = new HttpClient().Request(HttpClient.Method.Post, "index.php", headers, queryString);
[/csharp] [/csharp]
[/codeblocks] [/codeblocks]

View file

@ -16,7 +16,7 @@
[/gdscript] [/gdscript]
[csharp] [csharp]
var newNavigationMesh = new NavigationPolygon(); var newNavigationMesh = new NavigationPolygon();
var boundingOutline = new Vector2[] { new Vector2(0, 0), new Vector2(0, 50), new Vector2(50, 50), new Vector2(50, 0) }; Vector2[] boundingOutline = [new Vector2(0, 0), new Vector2(0, 50), new Vector2(50, 50), new Vector2(50, 0)];
newNavigationMesh.AddOutline(boundingOutline); newNavigationMesh.AddOutline(boundingOutline);
NavigationServer2D.BakeFromSourceGeometryData(newNavigationMesh, new NavigationMeshSourceGeometryData2D()); NavigationServer2D.BakeFromSourceGeometryData(newNavigationMesh, new NavigationMeshSourceGeometryData2D());
GetNode<NavigationRegion2D>("NavigationRegion2D").NavigationPolygon = newNavigationMesh; GetNode<NavigationRegion2D>("NavigationRegion2D").NavigationPolygon = newNavigationMesh;
@ -34,9 +34,9 @@
[/gdscript] [/gdscript]
[csharp] [csharp]
var newNavigationMesh = new NavigationPolygon(); var newNavigationMesh = new NavigationPolygon();
var newVertices = new Vector2[] { new Vector2(0, 0), new Vector2(0, 50), new Vector2(50, 50), new Vector2(50, 0) }; Vector2[] newVertices = [new Vector2(0, 0), new Vector2(0, 50), new Vector2(50, 50), new Vector2(50, 0)];
newNavigationMesh.Vertices = newVertices; newNavigationMesh.Vertices = newVertices;
var newPolygonIndices = new int[] { 0, 1, 2, 3 }; int[] newPolygonIndices = [0, 1, 2, 3];
newNavigationMesh.AddPolygon(newPolygonIndices); newNavigationMesh.AddPolygon(newPolygonIndices);
GetNode<NavigationRegion2D>("NavigationRegion2D").NavigationPolygon = newNavigationMesh; GetNode<NavigationRegion2D>("NavigationRegion2D").NavigationPolygon = newNavigationMesh;
[/csharp] [/csharp]

View file

@ -59,7 +59,7 @@
var pid = OS.create_process(OS.get_executable_path(), []) var pid = OS.create_process(OS.get_executable_path(), [])
[/gdscript] [/gdscript]
[csharp] [csharp]
var pid = OS.CreateProcess(OS.GetExecutablePath(), new string[] {}); var pid = OS.CreateProcess(OS.GetExecutablePath(), []);
[/csharp] [/csharp]
[/codeblocks] [/codeblocks]
See [method execute] if you wish to run an external command and retrieve the results. See [method execute] if you wish to run an external command and retrieve the results.
@ -105,8 +105,8 @@
var exit_code = OS.execute("ls", ["-l", "/tmp"], output) var exit_code = OS.execute("ls", ["-l", "/tmp"], output)
[/gdscript] [/gdscript]
[csharp] [csharp]
var output = new Godot.Collections.Array(); Godot.Collections.Array output = [];
int exitCode = OS.Execute("ls", new string[] {"-l", "/tmp"}, output); int exitCode = OS.Execute("ls", ["-l", "/tmp"], output);
[/csharp] [/csharp]
[/codeblocks] [/codeblocks]
If you wish to access a shell built-in or execute a composite command, a platform-specific shell can be invoked. For example: If you wish to access a shell built-in or execute a composite command, a platform-specific shell can be invoked. For example:
@ -116,8 +116,8 @@
OS.execute("CMD.exe", ["/C", "cd %TEMP% && dir"], output) OS.execute("CMD.exe", ["/C", "cd %TEMP% && dir"], output)
[/gdscript] [/gdscript]
[csharp] [csharp]
var output = new Godot.Collections.Array(); Godot.Collections.Array output = [];
OS.Execute("CMD.exe", new string[] {"/C", "cd %TEMP% && dir"}, output); OS.Execute("CMD.exe", ["/C", "cd %TEMP% && dir"], output);
[/csharp] [/csharp]
[/codeblocks] [/codeblocks]
[b]Note:[/b] This method is implemented on Android, Linux, macOS, and Windows. [b]Note:[/b] This method is implemented on Android, Linux, macOS, and Windows.

View file

@ -61,14 +61,14 @@
public override Godot.Collections.Array<Godot.Collections.Dictionary> _GetPropertyList() public override Godot.Collections.Array<Godot.Collections.Dictionary> _GetPropertyList()
{ {
return new Godot.Collections.Array<Godot.Collections.Dictionary>() return
{ [
new Godot.Collections.Dictionary() new Godot.Collections.Dictionary()
{ {
{ "name", "FakeProperty" }, { "name", "FakeProperty" },
{ "type", (int)Variant.Type.Int } { "type", (int)Variant.Type.Int },
} },
}; ];
} }
[/csharp] [/csharp]
[/codeblocks] [/codeblocks]
@ -137,11 +137,11 @@
} }
} }
private Godot.Collections.Array<int> _numbers = new(); private Godot.Collections.Array<int> _numbers = [];
public override Godot.Collections.Array<Godot.Collections.Dictionary> _GetPropertyList() public override Godot.Collections.Array<Godot.Collections.Dictionary> _GetPropertyList()
{ {
var properties = new Godot.Collections.Array<Godot.Collections.Dictionary>(); Godot.Collections.Array<Godot.Collections.Dictionary> properties = [];
for (int i = 0; i < _numberCount; i++) for (int i = 0; i < _numberCount; i++)
{ {
@ -322,14 +322,14 @@
public override Godot.Collections.Array<Godot.Collections.Dictionary> _GetPropertyList() public override Godot.Collections.Array<Godot.Collections.Dictionary> _GetPropertyList()
{ {
return new Godot.Collections.Array<Godot.Collections.Dictionary>() return
{ [
new Godot.Collections.Dictionary() new Godot.Collections.Dictionary()
{ {
{ "name", "FakeProperty" }, { "name", "FakeProperty" },
{ "type", (int)Variant.Type.Int } { "type", (int)Variant.Type.Int },
} },
}; ];
} }
[/csharp] [/csharp]
[/codeblocks] [/codeblocks]
@ -416,19 +416,19 @@
]) ])
[/gdscript] [/gdscript]
[csharp] [csharp]
AddUserSignal("Hurt", new Godot.Collections.Array() AddUserSignal("Hurt",
{ [
new Godot.Collections.Dictionary() new Godot.Collections.Dictionary()
{ {
{ "name", "damage" }, { "name", "damage" },
{ "type", (int)Variant.Type.Int } { "type", (int)Variant.Type.Int },
}, },
new Godot.Collections.Dictionary() new Godot.Collections.Dictionary()
{ {
{ "name", "source" }, { "name", "source" },
{ "type", (int)Variant.Type.Object } { "type", (int)Variant.Type.Object },
} },
}); ]);
[/csharp] [/csharp]
[/codeblocks] [/codeblocks]
</description> </description>
@ -494,7 +494,7 @@
[/gdscript] [/gdscript]
[csharp] [csharp]
var node = new Node3D(); var node = new Node3D();
node.Callv(Node3D.MethodName.Rotate, new Godot.Collections.Array { new Vector3(1f, 0f, 0f), 1.571f }); node.Callv(Node3D.MethodName.Rotate, [new Vector3(1f, 0f, 0f), 1.571f]);
[/csharp] [/csharp]
[/codeblocks] [/codeblocks]
[b]Note:[/b] In C#, [param method] must be in snake_case when referring to built-in Godot methods. Prefer using the names exposed in the [code]MethodName[/code] class to avoid allocating a new [StringName] on each call. [b]Note:[/b] In C#, [param method] must be in snake_case when referring to built-in Godot methods. Prefer using the names exposed in the [code]MethodName[/code] class to avoid allocating a new [StringName] on each call.

View file

@ -369,7 +369,7 @@
print(array.hex_encode()) # Prints: 0b2eff print(array.hex_encode()) # Prints: 0b2eff
[/gdscript] [/gdscript]
[csharp] [csharp]
var array = new byte[] {11, 46, 255}; byte[] array = [11, 46, 255];
GD.Print(array.HexEncode()); // Prints: 0b2eff GD.Print(array.HexEncode()); // Prints: 0b2eff
[/csharp] [/csharp]
[/codeblocks] [/codeblocks]

View file

@ -54,13 +54,13 @@
[/gdscript] [/gdscript]
[csharp] [csharp]
var polygonPathFinder = new PolygonPathFinder(); var polygonPathFinder = new PolygonPathFinder();
var points = new Vector2[] Vector2[] points =
{ [
new Vector2(0.0f, 0.0f), new Vector2(0.0f, 0.0f),
new Vector2(1.0f, 0.0f), new Vector2(1.0f, 0.0f),
new Vector2(0.0f, 1.0f) new Vector2(0.0f, 1.0f)
}; ];
var connections = new int[] { 0, 1, 1, 2, 2, 0 }; int[] connections = [0, 1, 1, 2, 2, 0];
polygonPathFinder.Setup(points, connections); polygonPathFinder.Setup(points, connections);
GD.Print(polygonPathFinder.IsPointInside(new Vector2(0.2f, 0.2f))); // Prints True GD.Print(polygonPathFinder.IsPointInside(new Vector2(0.2f, 0.2f))); // Prints True
GD.Print(polygonPathFinder.IsPointInside(new Vector2(1.0f, 1.0f))); // Prints False GD.Print(polygonPathFinder.IsPointInside(new Vector2(1.0f, 1.0f))); // Prints False
@ -91,13 +91,13 @@
[/gdscript] [/gdscript]
[csharp] [csharp]
var polygonPathFinder = new PolygonPathFinder(); var polygonPathFinder = new PolygonPathFinder();
var points = new Vector2[] Vector2[] points =
{ [
new Vector2(0.0f, 0.0f), new Vector2(0.0f, 0.0f),
new Vector2(1.0f, 0.0f), new Vector2(1.0f, 0.0f),
new Vector2(0.0f, 1.0f) new Vector2(0.0f, 1.0f)
}; ];
var connections = new int[] { 0, 1, 1, 2, 2, 0 }; int[] connections = [0, 1, 1, 2, 2, 0];
polygonPathFinder.Setup(points, connections); polygonPathFinder.Setup(points, connections);
[/csharp] [/csharp]
[/codeblocks] [/codeblocks]

View file

@ -571,7 +571,7 @@
print("---".join(fruits)) # Prints "Apple---Orange---Pear---Kiwi" print("---".join(fruits)) # Prints "Apple---Orange---Pear---Kiwi"
[/gdscript] [/gdscript]
[csharp] [csharp]
var fruits = new string[] {"Apple", "Orange", "Pear", "Kiwi"}; string[] fruits = ["Apple", "Orange", "Pear", "Kiwi"];
// In C#, this method is static. // In C#, this method is static.
GD.Print(string.Join(", ", fruits)); // Prints "Apple, Orange, Pear, Kiwi" GD.Print(string.Join(", ", fruits)); // Prints "Apple, Orange, Pear, Kiwi"

View file

@ -546,7 +546,7 @@
print("---".join(fruits)) # Prints "Apple---Orange---Pear---Kiwi" print("---".join(fruits)) # Prints "Apple---Orange---Pear---Kiwi"
[/gdscript] [/gdscript]
[csharp] [csharp]
var fruits = new string[] {"Apple", "Orange", "Pear", "Kiwi"}; string[] fruits = ["Apple", "Orange", "Pear", "Kiwi"];
// In C#, this method is static. // In C#, this method is static.
GD.Print(string.Join(", ", fruits)); // Prints "Apple, Orange, Pear, Kiwi" GD.Print(string.Join(", ", fruits)); // Prints "Apple, Orange, Pear, Kiwi"

View file

@ -641,13 +641,13 @@
[/gdscript] [/gdscript]
[csharp] [csharp]
// Set region, using Path2D node. // Set region, using Path2D node.
GetNode&lt;Window&gt;("Window").MousePassthrough = GetNode&lt;Path2D&gt;("Path2D").Curve.GetBakedPoints(); GetNode&lt;Window&gt;("Window").MousePassthroughPolygon = GetNode&lt;Path2D&gt;("Path2D").Curve.GetBakedPoints();
// Set region, using Polygon2D node. // Set region, using Polygon2D node.
GetNode&lt;Window&gt;("Window").MousePassthrough = GetNode&lt;Polygon2D&gt;("Polygon2D").Polygon; GetNode&lt;Window&gt;("Window").MousePassthroughPolygon = GetNode&lt;Polygon2D&gt;("Polygon2D").Polygon;
// Reset region to default. // Reset region to default.
GetNode&lt;Window&gt;("Window").MousePassthrough = new Vector2[] {}; GetNode&lt;Window&gt;("Window").MousePassthroughPolygon = [];
[/csharp] [/csharp]
[/codeblocks] [/codeblocks]
[b]Note:[/b] This property is ignored if [member mouse_passthrough] is set to [code]true[/code]. [b]Note:[/b] This property is ignored if [member mouse_passthrough] is set to [code]true[/code].