Hi MickD,
I failed to fully describe what I was talking about plus I had a function named "Initialize", so I'm sorry for the confusion.
Here is a link to C# feature that I am talking about:
How to: Initialize Objects by Using an Object Initializer (C# Programming Guide)https://msdn.microsoft.com/en-us/library/bb397680.aspx
In some of their examples they are using the compiler created default constructor to create a new Student with and "Object Initializer" to establish the properties of that student.
new StudentName
{FirstName
="Craig", LastName
="Playstead", ID
=116}
Each property is named and there is no mention in this web page of calling a function named or unnamed inside of the "Object Initializer".
The part of the previous post that I was trying to call attention to was this part which is in the "Object Initializer" portion of the PaletteSet(string name) constructor.
{
"Circle Radius",
new ElementHost
{AutoSize
= true, Dock
= DockStyle
.Fill, Child
= ctrl
} }
The intended function is not named but it appears from ILSPY that the compiler is using the variable types to choose this function:
public Palette Add(string name, Control control);
In this code:
new StudentName
{FirstName
="Craig", LastName
="Playstead", ID
=116}
Each property is accessed/identified by its name,
While in this code:
{
"Circle Radius",
new ElementHost
{AutoSize
= true, Dock
= DockStyle
.Fill, Child
= ctrl
} }
method is accessed/identified by its signature, as long as it is unique. If a class has more than one methods having the same signature, then they have to be accessed/identified by name. Since PaletteSet only has one method that takes 2 arguments - first is a String, second a Winform Control, thus, its name can be omitted. This is a C# language feature introduced in C# 3.0 when .NET 3.5 was released, I believe. I am not sure how do to it in VB.NET (probably something like "With...End With"?).
Either Class's Property, or Method, is really another class (meaning, everything is a object/class), thus the code:
var class1Instnace=new Class1 { Property1=expression1, Property2=expression2, Method1(arg1, arg2), Method2(arg1,arg2), {arg3, arg4, arg3},...};
In this case, Class has defined 3 methods: 2 methods accept the same types of 2 argument, while the 3rd method accept 3 argument. Therefore, in the "object initializer", if the code need to call all 3 methods, the first 2 have to be referred by name, and the third does not need to be called by name because of its unique signature. Of course, in the "object initializer", the required process logic decide which property to be initialized, which method need to be called.