0

Am kind confused, am try to the max and min length of the datatype int in my credit card details and telephone but i don't how to.

    [Required(ErrorMessage = "Telephone is required")]
    public int Telephone { get; set; }
    [Required(ErrorMessage = "Card Type is required")]
    [DisplayName("Card Type")]
    [StringLength(20)]
    public string CardType { get; set; }
    [Required(ErrorMessage = "Card Holders Name is required")]
    [DisplayName("Card Holders Name")]
    [StringLength(160)]
    public string CardHoldersName { get; set; }
    public int CardNumber { get; set; }
    public int CardExpMonth { get; set; }
    public int CardExpYear { get; set; }
    [ScaffoldColumn(false)]
    public decimal Total;
Matt Ball
  • 354,903
  • 100
  • 647
  • 710
user1335443
  • 11
  • 1
  • 3
  • 3
    Have you looked into the fun that is PCI compliance? Most people should't be storing CC data, at all. – ceejayoz Apr 17 '12 at 02:38

3 Answers3

4

Why are you storing the card number in an integer? Isn't a string more appropriate?

A string can handle any cc number you need. It could also handle (for further processing) cases where the user enters spaces between digits.

Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466
1

If you're going to store the CardNumber in a numeric format, use a long. A 32-bit signed int's max value is 2,147,483,647 — remember, int is synonymous with System.Int32 — which is not remotely large enough to hold a 16-digit credit card number. A long (aka System.Int64) has max value of 9,223,372,036,854,775,807, so it can hold every 18-digit number.

Note that a uint (unsigned 32-bit integer) is still not large enough, since its max value is merely 4,294,967,295.

Community
  • 1
  • 1
Matt Ball
  • 354,903
  • 100
  • 647
  • 710
0

use BigInteger Structure available in namespace System.Numerics

I think this would be useful to you

http://msdn.microsoft.com/en-us/library/system.numerics.biginteger.aspx

working with incredibly large numbers in .NET

http://www.codeproject.com/Articles/2728/C-BigInteger-Class

Nikhil Agrawal
  • 47,018
  • 22
  • 121
  • 208