IsSmallerThan generic extension method for C# and VB.NET

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#

Sample VB.NET


If you have any questions or suggestions feel free to rate this snippet, post a comment or Contact Us via Email.

Related links:

IsLargerThan generic extension method for C# and VB.NET

This is the IsLargerThan generic extension method, this extension method which is part of the Fesslersoft.Extensions. It should only work with numeric values.

Samples

Sample C#

Sample VB.NET

If you have any questions or suggestions feel free to rate this snippet, post a comment or Contact Us via Email.

Related links:

How to format a float to 2 decimal places in Objective-C

To format a float to 2 decimal places in Objective-C you can use the following snippet.

Sample Objective-C

NSString* formattedVariable = [NSString stringWithFormat:@"%.02f", myFloatVariable];

How to calculate PercentOf in PHP

To calculate PercentOf in PHP you can use the following snippet. It will calculate the percent of 2 given integers.

Sample PHP

Function PercentOf($int1, $int2) { 
	if ($int2 <= 0 || $int1 <=0){
		return 0;
	}
    $val1 = $int1 / $int2;  
    $retVal = $val1 * 100;  
    return $retVal;  
} 

If there is a 0 passed it will return 0.

IsLargerThan extension method for C# and VB.NET

If you need a IsLargerThan extension method you can use the follwing snippet.

Sample C#

public static bool IsLargerThan(this byte input, byte numberToCheck)
{
	return input > numberToCheck;
}

public static bool IsLargerThan(this sbyte input, sbyte numberToCheck)
{
	return input > numberToCheck;
}

public static bool IsLargerThan(this short input, short numberToCheck)
{
	return input > numberToCheck;
}
public static bool IsLargerThan(this ushort input, ushort numberToCheck)
{
	return input > numberToCheck;
}
public static bool IsLargerThan(this int input, int numberToCheck)
{
	return input > numberToCheck;
}

public static bool IsLargerThan(this uint input, uint numberToCheck)
{
	return input > numberToCheck;
}

public static bool IsLargerThan(this long input, long numberToCheck)
{
	return input > numberToCheck;
}
public static bool IsLargerThan(this ulong input, ulong numberToCheck)
{
	return input > numberToCheck;
}

public static bool IsLargerThan(this float input, float numberToCheck)
{
	return input > numberToCheck;
}

public static bool IsLargerThan(this double input, double numberToCheck)
{
	return input > numberToCheck;
}

public static bool IsLargerThan(this decimal input, decimal numberToCheck)
{
	return input > numberToCheck;
}

>h2>Sample VB.NET>/h2>

<System.Runtime.CompilerServices.Extension> _
Public Shared Function IsLargerThan(input As Byte, numberToCheck As Byte) As Boolean
	Return input > numberToCheck
End Function

<System.Runtime.CompilerServices.Extension> _
Public Shared Function IsLargerThan(input As SByte, numberToCheck As SByte) As Boolean
	Return input > numberToCheck
End Function

<System.Runtime.CompilerServices.Extension> _
Public Shared Function IsLargerThan(input As Short, numberToCheck As Short) As Boolean
	Return input > numberToCheck
End Function
<System.Runtime.CompilerServices.Extension> _
Public Shared Function IsLargerThan(input As UShort, numberToCheck As UShort) As Boolean
	Return input > numberToCheck
End Function
<System.Runtime.CompilerServices.Extension> _
Public Shared Function IsLargerThan(input As Integer, numberToCheck As Integer) As Boolean
	Return input > numberToCheck
End Function

<System.Runtime.CompilerServices.Extension> _
Public Shared Function IsLargerThan(input As UInteger, numberToCheck As UInteger) As Boolean
	Return input > numberToCheck
End Function

<System.Runtime.CompilerServices.Extension> _
Public Shared Function IsLargerThan(input As Long, numberToCheck As Long) As Boolean
	Return input > numberToCheck
End Function
<System.Runtime.CompilerServices.Extension> _
Public Shared Function IsLargerThan(input As ULong, numberToCheck As ULong) As Boolean
	Return input > numberToCheck
End Function

<System.Runtime.CompilerServices.Extension> _
Public Shared Function IsLargerThan(input As Single, numberToCheck As Single) As Boolean
	Return input > numberToCheck
End Function

<System.Runtime.CompilerServices.Extension> _
Public Shared Function IsLargerThan(input As Double, numberToCheck As Double) As Boolean
	Return input > numberToCheck
End Function

<System.Runtime.CompilerServices.Extension> _
Public Shared Function IsLargerThan(input As Decimal, numberToCheck As Decimal) As Boolean
	Return input > numberToCheck
End Function

How to check if a string is a number in C# and VB.NET

To check if a string is a number in C# and VB.NET you can use the following snippet.

Sample C#

public static bool IsNumeric(String input)
{
	double checkNumber;
	return double.TryParse(input, out checkNumber);
}

Sample VB.NET

Public Shared Function IsNumeric(input As [String]) As Boolean
	Dim checkNumber As Double
	Return Double.TryParse(input, checkNumber)
End Function