5

In C#, you can do something like this:

SomeClass someClass = new SomeClass () {
    SomeProperty = someValue
};

What is this syntax called?

Matthew
  • 28,056
  • 26
  • 104
  • 170

1 Answers1

18

Object initializer is the name.

Graviton
  • 81,782
  • 146
  • 424
  • 602
  • 1
    Wouldn't that be more like "Object initializer the name is. Hmmph! Much to learn you have." – Robert Groves Dec 30 '09 at 06:44
  • 2
    If so smart Yoda is, right order words in his sentences Yoda puts not why? – Eric Lippert Dec 30 '09 at 07:49
  • 3
    If I remember my Star Wars mythos correctly, Yoda spoke grammatically correct english up until the day he read *Chapter 7: Wisdom You Have Not, But Sound Like It You Will* of the book *Jedi Grammer Hacks: You May Have The Force, But Your Words Are Not Forceful*. ...or I just made that up. – Robert Groves Dec 30 '09 at 16:38