❔ How to calculate event expression?

like
c#
var result = a+b-c+d-c+d-b+a;
c#
var result = a+b-c+d-c+d-b+a;
a,b,c,d are all events, and each of them contains more than one method. So what is result like?
10 Replies
Thinker
Thinker2y ago
What type are they?
thirteenbinary
thirteenbinaryOP2y ago
They are events. Like:
c#
delegate void F();
event F a, b, c, d;
c#
delegate void F();
event F a, b, c, d;
Thinker
Thinker2y ago
$tias
Thinker
Thinker2y ago
although I don't know if you can add and subtract delegate types like that
thirteenbinary
thirteenbinaryOP2y ago
But I just see the result but I don't know the rule.
MODiX
MODiX2y ago
thinker227#5176
REPL Result: Success
delegate void F();

F a = () => Console.WriteLine("a");
F b = () => Console.WriteLine("b");
F c = () => Console.WriteLine("c");
F d = () => Console.WriteLine("d");

var result = a + b - c + d - c + d - b + a;
result();
delegate void F();

F a = () => Console.WriteLine("a");
F b = () => Console.WriteLine("b");
F c = () => Console.WriteLine("c");
F d = () => Console.WriteLine("d");

var result = a + b - c + d - c + d - b + a;
result();
Console Output
a
d
d
a
a
d
d
a
Compile: 697.949ms | Execution: 124.181ms | React with ❌ to remove this embed.
Thinker
Thinker2y ago
a + b - c + d - c + d - b + a
a + b - c + d - c + d - b + a
If we think about it like algebra
+ a
+ b
- c (doesn't do anything)
+ d
- c (doesn't do anything)
+ d
- b (removes b)
+ a
+ a
+ b
- c (doesn't do anything)
+ d
- c (doesn't do anything)
+ d
- b (removes b)
+ a
So the result is that + b and - b cancel out, and the - cs don't do anything.
+ a
+ d
+ d
+ a
+ a
+ d
+ d
+ a
thirteenbinary
thirteenbinaryOP2y ago
You dismiss a condition, the event can contain more than one method. I want a more general rule like we know 1+1=2.
Accord
Accord2y ago
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.
Want results from more Discord servers?
Add your server