So I want to make a calcullator rpn with arralist so Read the comments in the code thas I want to do......Or can you give some advice for the rpn calculator..really I need some help..

using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace ConsoleApplication9
{
    class Program
    {
        static void Main(string[] args)
        {
            // RPN CALCULATOR SIMPLE
            int ope1, ope2;
            char operadp;
            char[] sepa = { ' ' };
            string operacion;
            
          // Here the user write the operation
            Console.WriteLine("escrina operacion");
            operacion = Console.ReadLine();
            //I Split the string 
            string[] cadena = operacion.Split(sepa);
            //Here I want scan each character and  IF  is a intiger =ope1
            //and IF is a Char = operado
            //And IF the operad = + or - or * or / I going to operate
            foreach (int i in cadena)
            { 
            if( cadena is equals int)
            {
            
            }
            }


            


        }
    }
}

This an example

foreach(char c in str)
{
if(c .... //your condition
}

You can use TryParse to see if the token string is an integer and then act accordingly. (I don't have a compiler at this computer so my syntax might be off, but you should get the idea).

foreach(string token in cadena)
{
   int value;
   if(int.TryParse(token, out value) == false)
   {
      // This is a character string
      // TBD: Do stuff with character strings
   }
   else
   {
      // This is an integer string
      // TBD: Do stuff with integers, result is in value
   }
}

Note: You should verify that cadena contains tokens before calling foreach.

I think it makes more sense to write it like this:

int value;
foreach(string token in cadena)
{
   if(int.TryParse(token, out value))
   {
      // This is an integer string
      // TBD: Do stuff with integers, result is in value
   }
   else
   {
      // This is a character string
      // TBD: Do stuff with character strings
   }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.