This is the IsSmallerThan generic extension method, this extension method which is part of the Fesslersoft.Extensions. It should only work with numeric values.
Samples
Sample C#
public static bool IsSmallerThan<TOne, TTwo>(this TOne baseValue, TTwo checkValue) where TOne : struct,IComparable, IComparable<TOne>, IConvertible, IEquatable<TOne>, IFormattable where TTwo : struct,IComparable, IComparable<TTwo>, IConvertible, IEquatable<TTwo>, IFormattable { return Convert.ToDouble(baseValue) < Convert.ToDouble(checkValue); }
Sample VB.NET
<System.Runtime.CompilerServices.Extension> _ Public Shared Function IsSmallerThan(Of TOne As {Structure, IComparable, IComparable(Of TOne), IConvertible, IEquatable(Of TOne), IFormattable}, TTwo As {Structure, IComparable, IComparable(Of TTwo), IConvertible, IEquatable(Of TTwo), IFormattable})(baseValue As TOne, checkValue As TTwo) As Boolean Return Convert.ToDouble(baseValue) < Convert.ToDouble(checkValue) End Function
If you have any questions or suggestions feel free to rate this snippet, post a comment or Contact Us via Email.
Related links:
- Generic Methods (C# Programming Guide) (MSDN)
- where (generic type constraint) (C# Reference) (MSDN)
- struct (C# Reference) (MSDN)
- IComparable
Interface (MSDN) - IConvertible Interface (MSDN)
- IEquatable
Interface (MSDN) - IFormattable Interface (MSDN)