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