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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:32:00+00:00 2026-06-15T09:32:00+00:00

I am a novice C# coder and currently working on a Reverse polish notation

  • 0

I am a novice C# coder and currently working on a Reverse polish notation calculator. I created a method that will take care of the calculations but there are three lines in my code that are causing an error. After every = an operation is performed and then displayed. I am trying to grab the string from TxtInputBox and convert to integers but the following line is where I am getting a red squiggly line: string[] inputarray = TxtBoxInputbox.Text.Split();. Second when calling the function RPNCalc from button click Btn_Calc and assigning the textBoxes I receive another red squiggly line: RPNCalc(TxtInputBox, TxtOutputBox); I am not sure how to deal with these two errors that keep my form from working. Please help in making error free.

Code

namespace rpncalc
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void RPNCalc(TxtBoxInputbox, TxtBoxOutputbox)
        {
            Stack<int> stackone = new Stack<int>();
            stackone.Clear();
            string[] inputarray = TxtBoxInputbox.Text.Split();
            int end = inputarray.Length - 1;
            int numinput;
            int i = 0;

            do
            {
                if(inputarray[i] != "=" && inputarray[i] != "+" && inputarray[i] != "-" && inputarray[i] != "*" && inputarray[i] != "/")  
                {
                    try
                    {
                        numinput = Convert.ToInt32(inputarray[i]);
                        stackone.Push(numinput);
                    }
                    catch
                    {
                        MessageBox.Show("Please check the input");
                    }
                }

                    else if (inputarray[i]== "+")
                    {
                        try
                        {
                            int store1 = stackone.Pop();
                            int store2 = stackone.Pop();
                            stackone.Push(store2 + store1);
                        }
                        catch
                        {
                        }
                    }

                    else if (inputarray[i]== "-")
                    {
                        try
                        {
                            int store1 = stackone.Pop();
                            int store2 = stackone.Pop();
                            stackone.Push(store2 + store1);
                        }
                        catch
                        {
                        }
                    }

                    else if (inputarray[i]== "+")
                    {
                        try
                        {
                            int store1 = stackone.Pop();
                            int store2 = stackone.Pop();
                            stackone.Push(store2 + store1);
                        }
                        catch
                        {
                        }
                    }

                    else if (inputarray[i]== "*")
                    {
                        try
                        {
                            int store1 = stackone.Pop();
                            int store2 = stackone.Pop();
                            stackone.Push(store2 + store1);
                        }
                        catch
                        {
                        }
                    }

                    else if (inputarray[i]== "/")
                    {
                        try
                        {
                            int store1 = stackone.Pop();
                            int store2 = stackone.Pop();
                            stackone.Push(store2 + store1);
                        }
                        catch
                        {
                        }
                    }

            }
            while(i < end && inputarray[i]!= "=" && stackone.Count != 0);
            string txtout = TxtInputBox + " " + stackone.Pop().ToString() + Environment.NewLine;
            TxtOutputBox.AppendText(txtout);
            TxtInputBox.Clear();

        }

        private void Btn_Calc_Click(object sender, EventArgs e)
        {
            RPNCalc(TxtInputBox, TxtOutputBox);
        }

    }
}

enter image description here

  • 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-15T09:32:02+00:00Added an answer on June 15, 2026 at 9:32 am

    Your RPNCalc method signature is missing the types for the parameters. Did you mean:

    private void RPNCalc(TextBox TxtBoxInputbox, TextBox TxtBoxOutputbox)
    

    Side note, as RPNCalc is a member function of the form, it already has access to members this.TxtBoxInputbox and this.TxtBoxOutputbox. So you do not actually need to pass it any parameters at all.

    While we are on the topic, if it were my code, I would probably rewrite the whole method with no parameters, to return an int (i.e. private int RPNCalc()) which would take whatever is in this.TxtBoxInputbox, do calculations, and return the result. The calling method could then do what it wants with the result (in this case, adding it to the output). However, this does go beyond the scope of the original question.

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

Sidebar

Related Questions

I am currently working with a code example that initially is designed to take
I am novice coder in C# and I am currently working with a report
A bit of background: I am currently working on an application that allows novice
I am a fairly novice Java programmer and I am currently working on a
I am currently in an introductory c++ class and am working assignment that sorts
I'm currently working on a website that you'll find here: http://steadfastdesignfirm.com/rgw/ . I used
This is the code that I'm currently working with, and I'm getting this problem.
Currently I'm working on a program that parses through a file and takes characters
I'm currently working on a project that requires session variables to store search information,
I'm currently working on a Silverlight app and need to convert XML data into

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.