title: function/method in a collection initializer c#
body: <p>can i insert a method/function in a collection initializer? i am trying to insert expression in the function within a collection initializer but the variable in the class is asking for the declaration of it's body. Thank you.</p>
  
  <pre><code>            List&lt;demo&gt; ags = new List&lt;demo&gt;()
              {
                  new demo { acst = "One", currUpd() = () =&gt;  { intba += totint; } ,  st = 1 &lt; 2},
                  new demo { acst = "Two", currUpd() = () =&gt;  { intba += intp; } = 0,  st = 1 &lt; 2 },
                  new demo { acst = "Three", currUpd() = () =&gt;  { intba += pp; },  st = 1 &lt; 2 }
              };
  
  
              var agss = ags.Select(x =&gt; new {acst = x.acst, currUpd = x.currUpd, st = x.st });
              foreach (var item in agss)
              {
                  if (item.st == true)
                  {
                      item.currUpd();
  
                  }
              }
  
  
              public class demo
              {
              public string acst { get; set; }
              public delegate void currUpd() { get; set; }
              public bool st { get; set; }
              }
  </code></pre>