I'm trying to display a credit card number as a string like #### #### #### ####
I tried:
txtbox.Text = string.Format("{0:#### #### #### ####}", ccNumber);
and it didn't work. Any ideas?
String.Format("{0:0000 0000 0000 0000}", number)
EDIT
I paste my comment here to made it readable:
ccNumber is an Int or a string? if it's an int it should work. if it's a string you need to do a
String.Format("{0:0000 0000 0000 0000}", (Int64.Parse("1234567812345678")))
You better you a masked textBox, and set the mask to:
this.maskedTextBox1.Mask = "0000 0000 0000 0000";
or set the string format to:
long number = 1234123412341234;
textBox1.Text = String.Format("{0:0000 0000 0000 0000}", number);
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