c# primary constructor notes
When declaring c# primary constructors such as below, the cardtype and valid is accessible to the class. I was thinking that it might also exposed as property too.
public class CreditCardValidationResult(string cardtype, bool valid)
{
}
If you want to do this then record would be an alternative. Only thing, is that the argument passed into the record needs to be pascal casing - otherwise when accessing the property of the class you get something like cardvaldiationResult.cardType instead of cardvalidationResult.CardType.
public record CreditCardValidationResult(string CardType, bool Valid);
Comments