This repository has been archived on 2022-08-05. You can view files and clone it, but cannot push or open issues or pull requests.
GradeCalc/GradeCalc/NCalcDoubleParser.cs

27 lines
715 B
C#

using System;
namespace GradeCalc
{
internal static class NCalcDoubleParser
{
public static double Parse(object nCalcOutput)
{
return nCalcOutput switch
{
bool n => (n ? 1 : 0),
byte n => n,
sbyte n => n,
short n => n,
ushort n => n,
int n => n,
uint n => n,
long n => n,
ulong n => n,
float n => n,
double n => n,
decimal n => (double) n,
_ => throw new ArgumentException("Type mismatch! (" + nCalcOutput.GetType() + ")")
};
}
}
}