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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:44:16+00:00 2026-05-31T11:44:16+00:00

I’ll exemplify, since I’m not sure if I’m asking the question correctly (English is

  • 0

I’ll exemplify, since I’m not sure if I’m asking the question correctly (English is not my primary language, plus I’m still learning C#).

I’ve started going through Project Euler, and decided to create an application to keep track of my results, and to put my little C# knowledge to test.

In a particular class I hold static functions that are used to solve each of the problems.

static class Answers()
{
  public static string A1(){...}
  public static string A2(){...}
  public static string A3(){...}
  //it goes on
}

Problem objects will be created like this (Problem class definition and object creation in runtime).

class Problem
{
  public string Description;
  public Solution SolutionFinder;

  public Problem(string Desc, Solution Solver)
  {
    this.Description = Desc;
    this.SolutionFinder = Solver;
  }

  public delegate string Solution();

  public string SolveProblem()
  {
    return SolutionFinder.Invoke();
  }
}

This is on my Form creation code:

{
  ...
  List<Problem> Euler = new List<Problem>();
  Euler.Add(new Problem("Find the sum of all the multiples of 3 or 5 below 1000.", Answers.A1));
  Euler.Add(new Problem("By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.", Answers.A2));
  Euler.Add(new Problem("What is the largest prime factor of the number 600851475143 ?", Answers.A3));
  ...
}

I got the classes and even the delegate thing to work correctly, and I’m thrilled with that. Then I finally decided to show the whole thing on a form. What I’m trying to show is: the description of the problem (this is done) and the code for each method (whatever is inside A1, A2, etc.) whenever I solve a problem using my form.

Is that clear? It’s just that I want my form to show the result and how I got the solution for each problem, but without having to retype the contents of each method just for display – the methods are already there.

And please don’t mind the messy code and overuse of public members: I understand it’s a bad practice, but for now I’m just trying to get through this personal project, and I believe it’s OK to do this here since it’s just a small learning experience.

Thanks.

[EDIT]
The format I’m looking for is:

void UpdateForm(int Current)
{
  Problem CurrentProblem = Euler[Current-1];
  string Desc = CurrentProblem.Description;
  string Code = CurrentProblem.SolutionFinder.Method.ReturnType.Name;
  //I got this far, but I need to display more than just the name of the method!
  ...
}

To Clarify

Given the method:

public static string A1() {
    var answer = 1 + 1;
    return answer.ToString();
}

Is it possible to obtain the following lines in a string..?

var answer = 1 + 1;
return answer.ToString();
  • 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-31T11:44:17+00:00Added an answer on May 31, 2026 at 11:44 am

    While it’s not the fanciest approach, if you set the “Copy to Output Directory” value to “Copy Always” (or “Copy if newer”) via the Properties of the source file (right-click/ Properties), you can parse the code file on your own while optimizing for your coding style.

    To add, are you aware that you are basically rebuilding NUnit, aside from the source code dump?

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I am writing an app with both english and french support. The app requests
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

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.