Please have a look
Auto-Implemented Properties[
^]
From your code,
AIproperty setvalues = new AIproperty();
console.write(setvalues.CustomerName);
setvalues.CustomerName
returns null and it should be, See below code how does Auto implemented properties CLR handle,
Step 1: I implemented a small class
public class AutoImplemetedProperties
{
public string PropertyOne { get; set; }
}
Step 2: related reflected code for the above class is,
public class AutoImplemetedProperties
{
[CompilerGenerated]
private string <PropertyOne>k__BackingField;
public string PropertyOne
{
[CompilerGenerated]
get
{
return this.<PropertyOne>k__BackingField;
}
[CompilerGenerated]
set
{
this.<PropertyOne>k__BackingField = value;
}
}
}
So the default value for
PropertyOne
is
null
and when we try to access, it returns
null
which it should be, unless we assign any value to it and then try to access.
As result, after you instantiate
AIproperty
and with out assigning any values to
CustomerName
, it should return
null
as we saw the above example code.
Hope it helps:)