PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, December 15, 2022

[FIXED] How can I find whether a number is even or odd using C#?

 December 15, 2022     c#, syntax     No comments   

Issue

I know that there is already a way to find if a number is even or odd using the modulus (What is the fastest way to find if a number is even or odd?). However, I was wondering if there is a C# function like Math.Even or Math.Odd. Is the only way to do this by using a modulus?


Solution

It may count as cheating, but if you use BigInteger, it has an IsEven method.

As stated in MSDN, calling this method is equivalent to:

value % 2 == 0;

Reference:

  • BigInteger.IsEven Property


Answered By - Victor Zakharov
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing