I have the following C# public classes:
public class ClassA
{
public byte var1;
public TypeX var2;
}
public class TypeX
{
public UInt16 num1;
public UInt32 num2;
}
(Names are simplified for this example and are not real)
What would this look like in Python? Specifically, how would var2 be created as an instance of TypeX?
So far I have the come up with the following Python classes:
class ClassA():
def __init__(self, var1, var2 = TypeX):
self.var1 = var1
self.var2 = var2
class TypeX():
def __init__(self, num1, num2):
self.num1 = num1
self.num2 = num2
However, I am nearly 100% sure this is not correct. Should ClassA inherit TypeX? Any guidance or explanations would be appreciated!
NullReferenceExceptionwhen you attempted to accessvar1orvar2fromClassA. This can be easily remedied with a constructor.