1#pragma warning disable 1587
17#pragma warning restore 1587
32 private const int CALC_SUCCESS = 0;
37 private const int CALC_ERROR = -1;
64 int returnCode = NativeMethods.CalcHandler((
int)kind, a, b, out
int result);
66 isSuccess: returnCode == CALC_SUCCESS,
97 if (!result.IsSuccess)
101 $
"Calculation failed: kind={kind}, a={a}, b={b}, errorCode={result.ErrorCode}");
ネイティブ calc ライブラリを使用して基本的な整数演算を実行するための メソッドを提供します。
static int CalculateOrThrow(CalcKind kind, int a, int b)
計算を実行し、失敗した場合は例外をスローします。
static CalcResult Calculate(CalcKind kind, int a, int b)
指定された演算種別に基づいて計算を実行します。
static CalcResult Divide(int a, int b)
第一の整数を第二の整数で除算します。
static CalcResult Add(int a, int b)
2 つの整数を加算します。
static CalcResult Multiply(int a, int b)
2 つの整数を乗算します。
static CalcResult Subtract(int a, int b)
第一の整数から第二の整数を減算します。