-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddToStructProperty.cs
More file actions
44 lines (36 loc) · 934 Bytes
/
Copy pathAddToStructProperty.cs
File metadata and controls
44 lines (36 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.Collections.Generic;
public static class Program {
public const int ShockwaveVelocity = 384;
public const int KinematicObstructionGridSize = 8;
public static void Main (string[] args) {
var objects = new List<Obj> {
new Obj(), new Obj(), new Obj()
};
for (int i = 0; i < objects.Count; i++) {
Str d = new Str { Value = i };
objects[i].Property += d;
}
foreach (var o in objects)
Console.WriteLine(o.Property.Value);
}
}
public class Obj {
private int p;
public Str Property {
get {
return new Str { Value = p };
}
set {
p = value.Value;
}
}
}
public struct Str {
public int Value;
public static Str operator + (Str lhs, Str rhs) {
return new Str {
Value = lhs.Value + rhs.Value
};
}
}