回答編集履歴

1

追記

2022/02/20 04:59

投稿

ozwk
ozwk

スコア13528

test CHANGED
@@ -12,3 +12,22 @@
12
12
  ```
13
13
 
14
14
 
15
+ ---
16
+
17
+
18
+ ```C#
19
+ class Item{
20
+ public string Name{get;}
21
+ public Item(string name){
22
+ Name = name;
23
+ }
24
+ public static explicit operator Item(string s) => new Item(s);
25
+ // ... 等値比較など適宜実装
26
+ }
27
+ ```
28
+
29
+
30
+ ```C#
31
+ if("hoge" == (Item)"hoge"){} //error
32
+ ```
33
+