THE SHORT ANSWER

Use value % 2 != 0 for integer parity. TryParse lets the caller distinguish an invalid input from a valid even result.

A C# integer is odd when its remainder after division by two is nonzero. Use a signed integer type for whole-number counts and keep parsing separate from the predicate. The following console example accepts signed decimal text and reports invalid input without treating it as even.

A signed integer example

using System;
using System.Globalization;

static bool IsOdd(long value) => value % 2 != 0;

string text = "-73";
if (long.TryParse(text, NumberStyles.AllowLeadingSign,
                  CultureInfo.InvariantCulture, out long value))
{
    Console.WriteLine(IsOdd(value)); // True
}
else
{
    Console.WriteLine("Enter a signed 64-bit integer.");
}

Keep parsing errors visible

The explicit parsing style accepts a leading plus or minus sign. It does not ask the parser to accept surrounding whitespace, thousands separators, or a decimal point. This is one useful policy for a machine-readable input field; a human-facing form may choose a different policy. The Int64.TryParse documentation lists the overloads and their parsing behavior.

Check the boolean returned by TryParse before using its output. If parsing fails, the output value alone must not become the answer to the user's question. Otherwise, an invalid string can accidentally travel through a fallback zero and appear to be a successfully checked even number.

Check negative values and numeric limits

C# remainder can be negative when the left operand is negative. For example, -73 % 2 is -1, so comparing with positive one is incorrect for this input. Microsoft's arithmetic operator reference explains that behavior. The nonzero comparison handles both negative and positive odd integers.

Test the arithmetic independently of the text parser:

Console.WriteLine(IsOdd(-74));           // False
Console.WriteLine(IsOdd(0));             // False
Console.WriteLine(IsOdd(long.MinValue)); // False
Console.WriteLine(IsOdd(long.MaxValue)); // True

The helper does not need Math.Abs. Avoiding an absolute-value conversion also avoids introducing an extra edge case at the smallest signed integer. The divisor is always two, so the code does not depend on caller-supplied division settings or a nonzero-divisor check.

Handle missing values and measurements

Use a separate policy for long?. A missing nullable value is not mathematically even or odd. You can reject it, leave a result empty, or produce a result object with a missing-input state. Automatically calling GetValueOrDefault would choose zero and hide that distinction.

Do not pass decimal measurements through an integer cast just to reuse this function. A quantity such as 73.9 needs validation or an explicitly documented rounding decision before parity makes sense. Test parser rejection and arithmetic results separately so changes to an input form cannot quietly change what the odd-number helper means.

For a CSV import, retain the original field beside any parsing error. That makes it possible to correct the source record without guessing which normalization or conversion produced a result.

Sources & further reading

Want to check a number?Try the calculator ↗