❔ Is there a way to remove brackets from empty methods?
E.g.
I don't need those brackets. Can't I make this look prettier?
19 Replies
No
As far as I know, no
why would you do that?
Most you can do is
to put it all on the same line
To save two lines for every 'empty' method that I don't need.
Yeah, figured as much.
Though CodeRush automatically "fixes" that and puts them in two new lines. x)
public Ctor(int x) : base(x);
is a thing I wish you could do but you unfortunately can't PRs welcome
😈
public MismatchedEnumLengthsException() : base("lol") => _ = this;
public MismatchedEnumLengthsException() : base("lol") => = new {};
public MismatchedEnumLengthsException() : base("lol") => GetType();
public MismatchedEnumLengthsException() : base("lol") => Array.Empty<int>();
public MismatchedEnumLengthsException() : base("lol") => ((Action?)default)?.Invoke();
i remember i did something like calling an empty action or something, somewhere
Just put them together at the end of the same line
Is there actually a reason you can inline methods but not constructors?
wdym?
public string Foo() => "foo";
Or in the case of a constructor would be public Foo() => Prop = 1;
pretty sure you can do that?
Right, just remembered
my bad
jcotton42#1663
REPL Result: Success
Compile: 426.565ms | Execution: 37.465ms | React with ❌ to remove this embed.
like, i wrote 5 inline constructors just above your post...................
You can do cool stuff with inline ctors and tuples
Angius#1586
REPL Result: Success
Result: Foo
Compile: 490.760ms | Execution: 52.068ms | React with ❌ to remove this embed.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.
Was this issue resolved? If so, run /close
- otherwise I will mark this as stale and this post will be archived until there is new activity.