Can someone explain this syntax in C#? -
when creating objects in java i'm used following syntax:
objectx1 = new objectx(some arguments);
while looking on project in c# came across following code:
_createsample = new func<samplebase>[] { () => new skeletonmappingsample(); }
i need 2 things explained me. first, how creating object without brackets , parameter list , instead using {} expressions work?
next, expression between {} mean?
the code found:
_createsample = new func<samplebase>[] { () => new skeletonmappingsample(); }
is notation creating array , initialising values.
which same as:
_createsample = new func<samplebase>[1]; _createsample[0] = () => new skeletonmappingsample();
except in { }
version bounds set compiler based on how many elements you've added between { }
for objects:
someclass abc = new someclass() { someproperty = "somevalue", }
is way of creating object , setting property values, it's same as:
someclass abc = new someclass(); abc.someproperty = "somevalue";
Comments
Post a Comment