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

  • SEARCH
  • Home
  • 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 6326347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:04:20+00:00 2026-05-24T17:04:20+00:00

I am a new to C#, I need a small help on how can

  • 0

I am a new to C#, I need a small help on how can I pass multiple parameters between the classes?
Below is a small example but my parameters will more than the 10. Is there another way to this?

public StreamStructure(String name, string id, string classname, int number)
    {
        this.name = name;
        this.id = id;
        this.classname = classname;
        this.number = number;
    }

List ——

List<abc> don = new List<abc>();
            foreach (XmlElement abc_cdb in abc_cdbs)
            {

                abc.Name = abc_cdb.GetAttribute("NAME");
                abc.Id = abc_cdb.GetAttribute("id");
                abc.Clssname = abc_cdb.GetAttribute("classname");
                abc.number = Convert.ToInt32(abc_cdb.GetAttribute("number"));
                don.Add(abc);


               }

I have used as suggested in ans but I am trying to create a list in C# my first record gets replaced with the 2nd one, since the fields in MyDTO are defined as public. Do you have any idea how to fix this?

  • 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-05-24T17:04:21+00:00Added an answer on May 24, 2026 at 5:04 pm

    You are probably better off using C# Initializers or a Data Transfer Object than a large number of constructor parameters. Or combine the two.

    public class MyDTO
    {
       String Name { get; set; }
       String Id { get; set; }
       String ClassName { get; set; }
       int Number { get; set; }
    }
    
    var MyDTO = new MyDTO() 
    {
       Name      = Name,
       Id        = Id,
       ClassName = ClassName,
       Number    = Number
    }
    
    var stream = new StreamStructure(MyDTO) 
    

    To create a list of these objects as in your example, create a new DTO within the loop body.

    var don = new List<MyDTO>(); 
    foreach (XmlElement abc_cdb in abc_cdbs) 
    {
        var abc = new MyDTO()
        {
            Name = abc_cdb.GetAttribute("NAME");
            Id = abc_cdb.GetAttribute("id");
            ClassName = abc_cdb.GetAttribute("classname");
            Number = Convert.ToInt32(abc_cdb.GetAttribute("number"));
        };
    
        don.Add( abc );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using virtual machines for development,but each time I need a new VM,
I need add a new user group for mediawiki. The new group has more
I need help to replace all \n (new line) caracters for in a String,
hi i am new to iphone.i have done a small application but what i
I need some help with my xpath query. I can get this code to
I'm new to Java, and I need some help working on this program. This
Once again I need some help. I'm creating a multiple file upload function with
I'm new to posting on these forums but have come here multiple times for
I already read/tried these posts but that didn't help: Display multiple lines within a
I am working on a small project and need your help. Here are the

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.