@@ -12,27 +12,15 @@ private Option()
1212 {
1313 }
1414
15- /// <summary>
16- /// Overrides the ToString method to return both the type and, if present, the value.
17- /// </summary>
18- /// <returns></returns>
19- public override string ToString ( )
20- {
21- return this switch
22- {
23- Some some => $ "Some({ some . Value } )",
24- None => "None" ,
25- _ => "Invalid"
26- } ;
27- }
28-
2915 /// <summary>
3016 /// Implicitly converts a value to an <see cref="Option{T}" />.
3117 /// </summary>
3218 /// <param name="value">The value to wrap. Null becomes <see cref="None" />.</param>
3319 public static implicit operator Option < T > ( T value )
3420 {
35- return value != null ? new Some ( value ) : None . Instance ;
21+ return value != null
22+ ? new Some ( value )
23+ : None . Instance ;
3624 }
3725
3826 /// <summary>
@@ -73,6 +61,15 @@ public Some(T value)
7361 /// The wrapped value.
7462 /// </summary>
7563 public T Value { get ; }
64+
65+ /// <summary>
66+ /// Overrides the ToString method to return both the type and the value.
67+ /// </summary>
68+ /// <returns>The overridden ToString</returns>
69+ public override string ToString ( )
70+ {
71+ return $ "Some({ Value } )";
72+ }
7673 }
7774
7875 /// <summary>
@@ -81,12 +78,21 @@ public Some(T value)
8178 public sealed class None : Option < T >
8279 {
8380 /// <summary>
84- /// A helper method to create an instance of <see cref="None" />
81+ /// A helper method to create an instance of <see cref="Option{T}. None" />
8582 /// </summary>
8683 public static readonly None Instance = new ( ) ;
8784
8885 private None ( )
8986 {
9087 }
88+
89+ /// <summary>
90+ /// Overrides the ToString method to return the type as a simple string.
91+ /// </summary>
92+ /// <returns>The overridden ToString</returns>
93+ public override string ToString ( )
94+ {
95+ return "None" ;
96+ }
9197 }
9298}
0 commit comments