I took this code from elsewhere in order to show and hide forms effectively. Whilst I understand most of it, I don’t understand what get does in this context and in general. can this be explained?
WinForms
public class FormProvider
{
public static Form1 frm1
{
get
{
if (_frm1 == null)
{
_frm1 = new Form1();
}
return _frm1;
}
}
It’s nothing else other than syntax wrapper over automatically generated function
So every time you reference
FormProvider.frm1, it’s like you are callingFormProvider.get_frm1()In fact if you try to code something like this:
it will give compile-time error, as there is a collision of definitions.