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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:02:43+00:00 2026-06-13T04:02:43+00:00

I feel bad for asking this when there are so many questions that are

  • 0

I feel bad for asking this when there are so many questions that are related but I was not able to find/understand the answer I am looking for.

// 2. Develop a program to convert currency X to currency Y and visa versa.

using System;

class Problem2
{
    static void Main (string[] args)
    {
        while (true) {
            Console.WriteLine ("1. Currency Conversion from CAD to Won");
            Console.WriteLine ("2. Currency Conversion from Won to Cad");
            Console.Write ("Choose from the Following: (1 or 2)? ");
            int option = int.Parse( Console.ReadLine() );
            //double x;
            if (option == 1) {
                Console.WriteLine ("Type in the amount you would like to Convert CAD to Won: ");
                //double y =double.Parse( Console.ReadLine());
                //Console.WriteLine( cadToWon( y ) );
                Console.WriteLine( cadToWon( double.Parse( Console.ReadLine() ) ));
            }
            if (option == 2) {
                Console.WriteLine ("Type in the amount you would like to Convert Won to CAD: ");
                Console.WriteLine( wonToCad (double.Parse( Console.ReadLine())));
            }
        }
    }

    double cadToWon( double x )
    {
        return x * 1113.26;
    }

    double wonToCad( double x)
    {
        return x / 1113.26;
    }
}

This give me the Error messgae “An object reference is required for the non-static field, method, or property ‘Problem2…” I know that I’ll be able to run the program if I add static infront of the methods but I’m wondering why I need it (I think it’s because Main is static?) and what do I need to change in order to use these methods without adding static to them?

Thank you

  • 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-13T04:02:44+00:00Added an answer on June 13, 2026 at 4:02 am

    Since your Main method is static, cadToWon and wonToCad also have to be static if you want to call them from Main.

    static double cadToWon(double x) //...
    
    
    static double wonToCad(double x) //...
    

    The other option would be to break all of the logic of your Main, cadToWon, and wonToCad methods out into a new class, and then have you Main method simply set up and run that new class. But I suspect that might be beyond the scope of your assignment.


    To answer you question of why adding static makes this work:

    static methods are shared across all instances of a class. So no matter what instance of class Problem2 you’re in, there’s only one Main method that’s shared across all of them.

    cadToWon, however, is an instance method. It belongs to a particular instance of class Problem2.

    As a result, you can’t call cadToWon from Main, since Main doesn’t know what instance of Problem2 to call cadToWon on. Main doesn’t know what instance to call cadToWon on since Main doesn’t belong to any instance.

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

Sidebar

Related Questions

I feel bad for asking this, but I can't find any answer on the
I feel bad asking this question but I am currently not able to program
I feel pretty ignorant asking this, but would someone be able to explain to
I feel bad about mixing arrays with objects, but I'm not sure that I
I feel bad about not getting this. But, although I have read several articles
I feel bad about asking a question so simple, but I can't figure this
This is probably a very basic R question...and feel a bit bad about asking...but
I feel bad asking three questions in the space of two days but I
I feel silly for asking, but how do I get plan value in this
I feel like such a noob asking this but, for some reason a horizontal

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.