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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:58:27+00:00 2026-06-03T07:58:27+00:00

pretty straight-forward question, I get an error I don’t know how to solve, in

  • 0

pretty straight-forward question, I get an error I don’t know how to solve, in Visual C# Express, when I call the Romberg function in my main (I provided the error message at the appropriate line). I tried using this.Romberg too but it didn’t help. What should I do differently?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Romberg2
{
    class test
    {
        // the function
        double f(double x)
        {
            double f;
            f=8*(Math.Sqrt(1-x*x)-x);
            return f;
        }

        // The Integration function
        void Romberg(double a, double b, int n, double[,] R)
        {
            int i, j, k;
            double h, sum;

            h = b - a;
            R[0,0]=(h/2)*(f(a)+f(b));

            for (i=1; i<=n; i++)
            {
                h=h/2;
                sum=0;

                for (k=1; k <= (Math.Pow(2.0,i)-1); k +=2)
                    sum +=f(a+k*h);

                R[i,0]=R[i-1,0]/2+sum*h;

                for(j=1; j<=i; j++)
                    R[i,j]=R[i,j-1]+(R[i,j-1]-R[i-1,j-1])/(Math.Pow(4.0,j)-1);
            }
        }

        static void main(int argc, char [] argv)
        {
            double[,] R = new double [10,10];
            int n=5, digits=13;
            double a=0, b=1/Math.Sqrt(2.0);

            // Call the integrating function
            Romberg(a, b, n, R);//ERROR: An object reference is required for the non-static field, method, or property

            // Printout the diagram
            for(int i=0; i<n; i++)
            {
                for(int j=0; j<=i; j++)
                {
                    Console.WriteLine(R[i,j] + " ");
                }
                Console.WriteLine("\n");
            }

        }
    }
}
  • 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-06-03T07:58:28+00:00Added an answer on June 3, 2026 at 7:58 am

    Three problems:

    1) Main is not the correct format. It needs to be in one of these formats:

    static void Main() {...} 
    static void Main(string[] args) {... } 
    static int Main() {...} 
    static int Main(string [] args) {...}
    

    Just change it to ‘static void Main()’

    2) Make Romberg method static

    static void Romberg(double a, double b, int n, double[,] R)
    

    3) Make f method static:

    static double f(double x)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well, first of all sorry about this question it must be pretty straight forward
Pretty straight forward question, I have a GtkEntry widget that I want to set
This is a pretty straight forward question but I can't seem to figure out
My question is hopefully pretty straight forward. Upon submitting my form, I would like
It's a pretty straight forward question. I have my main window in a WPF
This is a pretty straight-forward question. I was wondering if there is some kind
It's a pretty straight forward question. I'd like to be able to provide feedback
I'm sure my question is pretty straight forward, and I've been looking for an
Pretty straight forward question. I'm quite happy with my simple text editor but sometimes
So my issue is pretty straight forward, since there is seemingly no callback for

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.