You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/scripting/c_sharp/c_sharp_exports.rst
+22-11Lines changed: 22 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,22 +48,33 @@ Exporting can work with fields and properties.
48
48
49
49
Exported members can specify a default value; otherwise, the `default value of the type <https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/default-values>`_ is used instead.
50
50
51
+
An ``int`` like ``_number`` defaults to ``0``. ``_text`` defaults to null
52
+
because ``string`` is a reference type.
53
+
51
54
.. code-block:: csharp
52
55
53
56
[Export]
54
-
privateint_number;// Defaults to '0'
57
+
privateint_number;
55
58
56
59
[Export]
57
-
privatestring_text; // Defaults to 'null' because it's a reference type
60
+
privatestring_text;
61
+
62
+
Default values can be specified for fields and properties.
63
+
64
+
.. code-block:: csharp
58
65
59
66
[Export]
60
-
privatestring_greeting="Hello World";// Exported field specifies a default value
67
+
privatestring_greeting="Hello World";
61
68
62
69
[Export]
63
-
publicstringGreeting { get; set; } ="Hello World"; // Exported property specifies a default value
0 commit comments