Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8665929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:36:17+00:00 2026-06-12T17:36:17+00:00

I need to initialize my object like below: var obj = new EduBranch {

  • 0

I need to initialize my object like below:

var obj = new EduBranch {
    Id = model.Id,
    WorklevelId = model.WorklevelId,
    EdulevelId = model.EdulevelId,
    Title = model.Title,
    StartEduYearId = model.StartEduYearId,
    EndEduYearId = model.EndEduYearId,
};

but in CodeDOM I could only find:

var objectCreate1 = new CodeObjectCreateExpression("EduBranch", 
    new CodeExpression[]{});  

and this is using parentheses to initialize instead of brackets.
is there a CodeDOM approach for this? ( I already make my code using stringBuilder but I’m looking for a CodeDOM approach ) thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:36:18+00:00Added an answer on June 12, 2026 at 5:36 pm

    The CodeDom doesn’t currently support object initializers (or collection initializers, for that matter).

    The CodeDom has fallen out of favor over the years, because of other technologies (T4 templates, for example).

    That said, because this line:

    var obj = new EduBranch {
        Id = model.Id,
        WorklevelId = model.WorklevelId,
        EdulevelId = model.EdulevelId,
        Title = model.Title,
        StartEduYearId = model.StartEduYearId,
        EndEduYearId = model.EndEduYearId,
    };
    

    Is effectively the same as:

    var obj = new EduBranch();
    
    obj.Id = model.Id;
    obj.WorklevelId = model.WorklevelId;
    obj.EdulevelId = model.EdulevelId;
    obj.Title = model.Title;
    obj.StartEduYearId = model.StartEduYearId;
    obj.EndEduYearId = model.EndEduYearId;
    

    You can use the CodeDOM to generate the above, and get the same

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seems like whenever we need to initialize an object, we need to immediately write
me need your adwise: i've got 2 classes, in first I initialize the object
In some languages, like php, you don't need to manually initialize each dimension of
Say I have a method signature like this: protected override void Initialize(params object[] parameters)
All my MooTools classes look like this: myClass = new Class({ initialize: function(options) {
I need to initialize few objects, it can take a while so I want
I'm writing a web application and need to initialize some parameters that I'm pulling
I am writing a program in C++ and I need to initialize an array
To initialize an int array with all zeros, do I need to use: int
I have a class: class One def initialize; end end I need to create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.