My code has this for PhraseNum:
public string PhraseNum { get => _phraseNum; set => SetProperty(ref _phraseNum, value); }
What I would like is for instead of just displaying the number, that it displays something like this:
Id: 00044
So with the characters "Id:" in front, then a space and then padded to five digits.
Simplest way is to call the ToString method on the int object with a format:
using System.Globalization;
int _phraseNum = 123;
_phraseNum.ToString("Id: 00000", CultureInfo.InvariantCulture); //outputs "Id: 00123"
public string PhraseNum { get => $"Id: {_phraseNum:D5}"; set => SetProperty(ref _phraseNum, value); }
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