I have a dynamic data of 0001, since it is dynamic it can change based on the data given. it could be 01 or 001 or 0001. to derive this value i have a code of
var placeholderValue = 4; //number can be dynamic.
var intFormattedValue = String.Format($"{{0:D{palceholderValue}}}", 1);
var parasedValue = Int32.Parse(intFormattedValue); //output 0001
if the placeholderValue above is 4, the output would be 0001 if it is 3 then 001 then if 2 01.
What i want to get is if the value is 0001 then it would return 9999 if the value is 001 then 999 if 01 then 99.
You can try to use Math.Pow method for 10 power and some calculation get the maximum value
Math.Pow(10, placeholderValue) - 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With