Not even close. I cannot even guess where did you get such ideas. What you are trying to do under init
looks line constructor and belongs to a constructor.
As to real init
it simply means “initialization-only”. This is the accessor used to make compilation fail if some code tries a write operation on a property except the constructor of the class having this property.
This is an example
class ReadWritePropertyDemo {
internal ReadWriteDemo() {
ReadableInternallyInitOnly = 42; // only here
ReadablePubliclyAndWritablePrivately = 43; // and by other methods
// of this class,
// see below
}
void SetterForOne(int value) {
ReadablePubliclyAndWritablePrivately = value;
}
internal int ReadableAndWritableInternally { get; set; }
public int ReadablePubliclyAndWritablePrivately { get; private set; }
// write access only for derived classes in containing assembly:
public int ReadablePubliclyLimitedWrite
{ get; private protected set; }
public int ReadablePubliclyAndWritableByDerivedClasses
{ get; protected set; }
internal int ReadableInternallyInitOnly { get; init; }
// and a lot more combinations with public,
// internal, private, internal protected, private protected...
}