Hi everyone. I'm currently working on a project with c#, and had some questions about classes. I'm a python programmer, so bear with me ;) How would I make a class that has pre defined arguments? I.e. even if the user doesn't pass that arguement, the default value of it will take over. Here's an example in python (hopefully it will make some sense):
class A(): # constructor def __init__(self,name,age,height='5 feet'): self.name = name self.age = age self.height = height def say(self): print(self.height) >>> inst = A('Luke',61) >>> inst.say() >>> '5 feet' >>> >>> >>> inst2 = A('Mark',45,'6 feet, 3 inches') >>> inst2.say() >>> '6 feet, 3 inches'
So in this case, the variable height is already declared, even if the user doesn't specifiy it. How would I go about doing this in c#? I can't really think of a solution. Thanks!