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 6010807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:10:09+00:00 2026-05-23T02:10:09+00:00

I have a WinForms application that creates a huge, custom textfile. To do this

  • 0

I have a WinForms application that creates a huge, custom textfile. To do this requires the user to configure dozens of controls on the main form and then click a Submit button. What is the best way to pass all those control values to my Generator class? The problem is I’m ending up with 20+ parameters to pass to a Generate() method. I can group some of those into Config objects (i.e. the date/time controls can be passed into a DateTimeConfig object) and then pass these config objects into the Generate() method to minimize the number of parameters needed, but it still feels like there must be a better way. Any ideas?

EDIT: Thank you for your responses, but I was hoping for something other than a configuration object (as that’s what my OP mentioned). I guess what I was hoping for is some way to serialize the values of all the controls automatically, without having to build a custom object and then modify that everytime a control changes or gets added/removed.

  • 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-23T02:10:10+00:00Added an answer on May 23, 2026 at 2:10 am

    Look into Model Driven Development, where the parameters are grouped into business objects or data transfer objects (DTOs). This is a more intuitive way to group parameters than by datetime, etc.

    If you place those model objects in a separate project, you can pass those objects around the solution (from one method to another and one project to another) without having to serialize them or mess with long parameter list ordering. You can even nest model objects inside other model objects.

    In this example, notice you only have to change parameters in the Person object or the Address object and you never have to serialize or map anything:

    // this is my business model object
    public class Person
    {
        public int PersonId { get; set; }
        public string PersonName { get; set; }
    
        // notice the Address object nested in the Person class
        public Address HomeAddress { get; set; }
    }
    
    // this is another class that lives inside the person class
    public class Address
    {
        public string Street { get; set; }
        public string City { get; set; }
    }
    

    In one class you could have this method that receives a person with an address and passes the person to another class’s SavePerson class:

    public void ProcessPerson(Person person)
    {
        person.PersonName = "Robert";
    
        Address address = new Address();
        address.City = "Austin";
    
        person.Address = address;
    
        SavePerson(person);
    }
    

    Some other class (even in another project) can take that person and pass it to the persistence layer:

    public void SavePerson(Person person)
    {
        database.Save(person);
    }
    

    So if I want to add a State to the person I just change the Address class and I’m all done in one step, I don’t have to add the state field to all the method parameter lists:

     public class Address
     {
        public string Street { get; set; }
        public string City { get; set; }
    
        //  this is the new property
        public string State  { get; set; }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a winforms application that normally is at about 2-4% CPU. We are
I have C# winforms application that needs to start an external exe from time
I have a winforms application that presently ships with a chm file for context-sensitive
I have a winforms application that is doing the following: on each query: Db
I have an winforms application that was built using MVC. The controller is subscribing
I have a Winforms application that generates its own PrintDocument object for printing. It
We have a WinForms application that uses SQL server to store its data. To
I have a desktop (winforms) application that uses a Firebird database as a data
I have a MDI WinForms application that can perform several tasks. Each task is
I have a .net 3.5 WinForms application that runs fine on my machine, but

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.