C
C#14mo 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
LividOP14mo 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
SG9714mo ago
what does making a variable mean
Livid
LividOP14mo ago
with properties maybe?
linqisnice
linqisnice14mo 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
LividOP14mo ago
:(
SG97
SG9714mo ago
$close
MODiX
MODiX14mo ago
Use the /close command to mark a forum thread as answered
Livid
LividOP14mo ago
so there isn't a very short method? so shortest is Form form = new() { Height = 100, }?
linqisnice
linqisnice14mo 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