mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-01-11 19:44:55 +00:00
feat: added extension to convert from enum to ushort
This commit is contained in:
@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
### Added
|
||||
- Added extension method to convert from bool to ushort and back
|
||||
- Added extension method to cast enums to ushort value
|
||||
|
||||
## [3.0.0] - 2018-04-23
|
||||
### Added
|
||||
|
||||
@@ -52,5 +52,13 @@ namespace ICD.Common.Utils.Extensions
|
||||
int num = (int)(object)value;
|
||||
return ((int)(object)extends & num) == num;
|
||||
}
|
||||
|
||||
public static ushort ToUShort(this Enum extends)
|
||||
{
|
||||
if (extends == null)
|
||||
throw new ArgumentNullException("extends");
|
||||
|
||||
return (ushort)(object)extends;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user