32
1
using System;
2
3
public class Calc
4
{
5
public int num1 { get; set; }
6
public int num2 { get; set; }
7
public Calc(int n1, int n2)
8
{
9
num1 = n1;
10
num2 = n2;
11
}
12
13
// Overload to reverse each number's sign
14
// Using the unary minus operator
15
public static Calc operator -(Calc calc)
16
{
17
calc.num1 = -calc.num1;
18
calc.num2 = -calc.num2;
19
return calc;
20
}
21
}
22
23
public class Program
24
{
25
public static void Main()
26
{
27
Calc calc = new Calc(43, -21);
28
calc = -calc;
29
Console.WriteLine("Num1 = {0}", calc.num1);
30
Console.WriteLine("Num2 = {0}", calc.num2);
31
}
32
}
Cached Result
System.Collections.Generic.IEnumerable`1[Oi3uhq12409+someType]
System.Collections.Generic.List`1[Oi3uhq12409+someType]
First pass through the sequence:
{"Id":"1"}
{"Id":"2"}
{"Id":"3"}
{"Id":"4"}
{"Id":"5"}
Second pass through the sequence (should be the same as the first):
{"Id":"1"}
{"Id":"2"}
{"Id":"3"}
{"Id":"4"}
{"Id":"5"}
System.Collections.Generic.List`1[Oi3uhq12409+someType]
First pass through the sequence:
{"Id":"1"}
{"Id":"2"}
{"Id":"3"}
{"Id":"4"}
{"Id":"5"}
Second pass through the sequence (should be the same as the first):
{"Id":"1"}
{"Id":"2"}
{"Id":"3"}
{"Id":"4"}
{"Id":"5"}