title: Initialize Object Properties in One Line of Code
body: <h3>Question:</h3>
  
  <p>Hello All,</p>
  
  <p>Sorry that this is kind of a noob question.  I just don't know how to word this process, so I'm not sure what to Google for.  I'll put some C# code below that should explain what I'm trying to do.  I just don't know how to do it in VB.  Additionally, for future ref, if you could tell me what this process is called, it would be helpful to know.  Thanks in advance for your help.</p>
  
  <pre><code>// Here is a simple class
  public class FullName
  {
      public string First { get; set; }
      public char MiddleInintial { get; set; }
      public string Last { get; set; }
  
      public FullName() { }
  }
  
  /* code snipped */
  
  // in code below i set a variable equal to a new FullName 
  // and set the values in the same line of code
  FullName fn = new FullName() { First = "John", MiddleInitial = 'J', Last = "Doe" };
  Console.Write(fn.First);  // prints "John" to console
  </code></pre>
  
  <p>As I mentioned earlier, I am drawing blanks on what to search for so sorry if this question is a repeat.  I too hate reruns :)  So, please link me somewhere else if you find something.</p>
  
  <hr />
  
  <h3>Solution:</h3>
  
  <p>So thanks to the help of one of our members, I have found that the keyword is <code>With</code>.</p>
  
  <pre><code>Dim fn As New FullName() With { .First = "John", .MiddleInitial = "J"c, .Last = "Doe" }
  Console.Write(fn.First)  ' prints "John" to console
  </code></pre>