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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:42:18+00:00 2026-05-10T20:42:18+00:00

In an earlier question about how to return a string from a dialog window

  • 0

In an earlier question about how to return a string from a dialog window, yapiskan suggested overloading the child form’s ShowDialog() method to include an out parameter.

My question is whether or not this is a good approach in C#.

Here is some example code, based on yapiskan’s suggestion. In the child form (in this example, it’s a form with a textbox on it), you just need to add the ShowDialog overload and assign UI values to the out parameter:

public DialogResult ShowDialog(out string s) {     DialogResult result = this.ShowDialog();     s = this.textBox1.Text;     return result; } 

And to show the form and retrieve the entered text, you do this:

using (CustomDialog frm = new CustomDialog()) {     string s;     if (frm.ShowDialog(out s) == DialogResult.OK)     {         // do something with s     } } 

One advantage I can think of is that this approach forces the user of the CustomDialog form to get the information it contains through the form’s ShowDialog method (rather than from a who-knows-what-it’s-called method like GetMyData() or something).

  • 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. 2026-05-10T20:42:18+00:00Added an answer on May 10, 2026 at 8:42 pm

    Better to have a Public property/method and get the information.

    What would you do if you would need 3..4..5 informations, having 5 parameters out? More clean to have accessors to get your information from the Dialog.

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

Sidebar

Related Questions

So I asked a question earlier about retrieving high scores form an html page
Just a clarification from an earlier question about OO PHP. I've checked on the
Earlier today I asked a question about configuring log4net from code and got an
According to an earlier question about Visual Studio configurations , there's no way to
I asked a question earlier about which language to use for an AI prototype.
Ok, I asked a question earlier about Flex and ADO.NET Data Services but didn't
Earlier I asked a question about why I see so many examples use the
Earlier today I asked a question about environ , and one of the more
Earlier this week I ask a question about filtering out duplicate values in sequence
Relating to my earlier question , I want to ensure all the child objects

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.