Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Calculate Used Unit from Readings
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { Int64 intCheckDigit = 5; decimal CurrentReding = 99242.00M; decimal LastReading = 102364.88M; string strCheckDigitMaxNumber = ""; for (int i = 1; i <= intCheckDigit; i++) { strCheckDigitMaxNumber += "9"; } string strInput = CurrentReding.ToString(); try { strInput = strInput.TrimStart('0'); if (strInput == "" || strInput == "0" || strInput == null) strInput = "0.00"; } catch { strInput = "0.00"; } int CurrentReding_Digit = Convert.ToInt64(Convert.ToDecimal(strInput)).ToString().Length; strInput = LastReading.ToString(); int LastDegit_Digit = Convert.ToInt64(Convert.ToDecimal(strInput.TrimStart('0'))).ToString().Length; decimal decUsedUnit = 0; if (CurrentReding_Digit != LastDegit_Digit && CurrentReding < LastReading && LastDegit_Digit == intCheckDigit) { decimal decCheckDigitMaxNumber = Convert.ToInt64(strCheckDigitMaxNumber); decimal decMaxDigitRemainingReadingUnit = Convert.ToInt64(strCheckDigitMaxNumber) - LastReading; decUsedUnit = decMaxDigitRemainingReadingUnit + CurrentReding; } else { decUsedUnit = CurrentReding - LastReading; } Console.WriteLine(decUsedUnit); } } }
run
|
edit
|
history
|
help
0
Use ConcurrentQueue and ConcurrentDictionary with TPL (Simple example)
C# Truly Random
ByVal
Testing 10
Fórum ➡ Border of a string S with at least 3 non-overlapping solutions ( yield version ) ♦
Plt-D v.0.9.6 (Speed Vector)
Create Sealed Class Object & call sealed method with non sealed class
MyTime calculation
Linked list problem with remove
custom stack Implementation