Click here to Skip to main content
15,886,693 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
check te integer value.
List out the no. of ways to check integer in C#.

What I have tried:

trying to find possible but not get as much.
Posted
Updated 2-May-20 22:02pm
Comments
phil.o 2-May-20 18:14pm    
What do you mean exactly by 'check integer'?
verma.vivek 3-May-20 2:29am    
yes
phil.o 3-May-20 11:14am    
Sorry, this is the answer to a question which I did not ask.
OriginalGriff 3-May-20 3:09am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
Use the "Improve question" widget to edit your question and provide better information.

1 solution

See: c# - How to elegantly check if a number is within a range? - Stack Overflow[^]

A more generic way that also works for other variable types is mentioned here:
Is there a "between" function in C#? - Stack Overflow[^]
public static bool IsBetween<T>(this T item, T start, T end)
{
    return Comparer<T>.Default.Compare(item, start) >= 0
        && Comparer<T>.Default.Compare(item, end) <= 0;
}
 
Share this answer
 
v2
Comments
BillWoodruff 4-May-20 11:24am    
my vote of #1: irrelevant to OP's vague concern. all too typical of many of your recent answers.

do you really need "rep points" this bad ?
RickZeeland 4-May-20 12:20pm    
Well, let's wait and see what the OP thinks of it before jumping to conclusions :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900