I am new to programming so I don’t know what the terminology is and I apologize. I want to be able to write something that looks like this:
Label Label1 = new Label();
Label1.Text = DateTime.Now.ToString("MM.dd.yyyy");
But with my own objects:
Reciept ReciptForAirPlaneTicket = new Reciept();
ReciptForAirPlaneTicket.MOP = MOP.CreditCard.Visa("4111111111111111|0815");
Reciept ReciptForFood = new Reciept();
ReciptForFood.MOP = MOP.CreditCard.MasterCard("4222222222222222|0917");
Reciept ReciptForClothes = new Reciept();
ReciptForClothes.MOP = MOP.Cash;
Reciept ReciptForTools = new Reciept();
ReciptForTools.MOP = MOP.Check("12345");
I really am not trying to be lazy, but I have been looking for almost a day now and I don’t even know what to look for. I think I need to make at least a class but also a struct or something called enum but I really don’t know.
I am using C#.
It seems like an unusual approach to me, but to get the exact syntax, you could create a kind of factory pattern using a static class MOP.
Repeat for the other types, and then instantiate as required.