C
C#10mo ago
Livid

✅ shortcut

what's the shortest way of making a variable? for example:
/// NOT VALID CODE (i think)
Form form() {
Width = 100,
}
/// NOT VALID CODE (i think)
Form form() {
Width = 100,
}
9 Replies
Livid
Livid10mo ago
or
/// NOT VALID CODE (i think)
Form form {
Width = 100;
};

// or

Form form = new() {
Width = 100,
};
/// NOT VALID CODE (i think)
Form form {
Width = 100;
};

// or

Form form = new() {
Width = 100,
};
SG97
SG9710mo ago
what does making a variable mean
Livid
Livid10mo ago
with properties maybe?
linqisnice
linqisnice10mo ago
@Livid if you mean during initialization, constructor invocation is probably the least amount of code
var form = new Form(100);
var form = new Form(100);
Livid
Livid10mo ago
:(
SG97
SG9710mo ago
$close
MODiX
MODiX10mo ago
Use the /close command to mark a forum thread as answered
Livid
Livid10mo ago
so there isn't a very short method? so shortest is Form form = new() { Height = 100, }?
linqisnice
linqisnice10mo ago
you can create a positional record. Minimal ceremony.
public record Form(double Height);

Form form = new(100);
public record Form(double Height);

Form form = new(100);
Want results from more Discord servers?
Add your server
More Posts