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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:35:41+00:00 2026-05-23T09:35:41+00:00

Thanks for help with the question I just submitted about anonymous classes. Now I

  • 0

Thanks for help with the question I just submitted about anonymous classes. Now I understand more. Here’s a bit more of an example:

public class abc {
 public xx doAction() {
    return ( new { ID = 5, Name= "Dave" } );
 }
 public void doStart() {
    var a = doAction();
    var b = a.ID;
    var c = a.Name;
 }
}

So am I correct in saying that the most ideal way to do this would be to declare a class XYX and use it like this:

public class abc {
 public XYZ doAction() {
    return ( new XYZ { ID = 5, Name= "Dave" } );
 }
 public void doStart() {
    var a = doAction();
    var b = a.ID;
    var c = a.Name;
 }
}

The class would be only used for this one data transfer between the two methods.

  • 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-23T09:35:42+00:00Added an answer on May 23, 2026 at 9:35 am

    I think you meant: return new XYZ(5, “Dave”)
    Anyways, your solution is okay but there is no reason to create a new class simply to share data. You can use a hashtable/array/dictionary or whatever class suits you best to share data. If you want to do something special with the XYZ class, or it has methods you wish to call from it, then you would have to create a new class XYZ and return it. Though, if you just want to share data, use a data structure that’s already available to your use.

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

Sidebar

Related Questions

I have a show/hide toggle working well in multiple instances (thanks to help here
Thanks to pbos help and its program (published here , for xoring a big
Update Thanks to Marc's help the AlphaPagedList class is now available on CodePlex if
I just have a short question about switching the color of sifr objects on
I just asked another question here: global variable and reduce database accesses in PHP+MySQL
Thanks to the help in a previous question , I've got the following code
This may be the silliest question i have ever asked here, but i just
so far the syntax is not the problem but my question is more about
I posted a question before about a form submitting to asp. I am more
Thanks for help with explaining to me about IList and IEnumerable. I have marked

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.