Skip to content

Instantly share code, notes, and snippets.

@ozw-sei
Created December 2, 2016 06:38
Show Gist options
  • Save ozw-sei/0e3c63e21a250321da16ecfe9143978b to your computer and use it in GitHub Desktop.
Save ozw-sei/0e3c63e21a250321da16ecfe9143978b to your computer and use it in GitHub Desktop.
public interface IOption<T>:IEquatable<IOption<T>>, IEquatable<T>
{
bool IsDefined
{
get;
}
// Something Method
// ...
}
public struct InternalOption<T> : IOption<T>{
// 様々なInterfaceの実装
public override bool Equals (object obj)
{
var isOption = obj is IOption<T>;
if (isOption)
return Equals ((IOption<T>)obj);
if(obj is T){
return Equals ((T)obj);
}
return false;
}
/// ↓みたいな関数の実装
public static bool operator ==(IOption<T> option, T t){
if (option == null || t == null)
return false;
return option.Equals (t);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment