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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:43:40+00:00 2026-05-25T12:43:40+00:00

I want to do an application that pareses text. So far, I have a

  • 0

I want to do an application that pareses text. So far, I have a class called Result, that holds the value and type each part of an equation.

public enum ResultType
{
    Int32,
    Double,
    Boolean,
    Color,
    DateTime,
    String,
    Undefined,
    Void
}

public class Result
{
    public object Value { get; set; }
    public ResultType Type { get; set; }
}

Possible Result’s could be:

 5 : Int32
 true : Boolean 
 DADACC : Color 
 "Hello World!" : String 
 10.0 : Double 
 13/11/1986 : DateTime

Now I want to sum/divide/pow/… two Results but I really don´t want to do all the work. In C#, you can mix them all together and get an answer.

var value = "Hello" + 2.0 + 4 + DateTime.Today; (value = "Hello2413/09/2011 12:00:00 a.m.")

Is there an easy way to handle this? Or do I have to figure out all combos by myself? I´m thinking about something like:

var Operator = "+"; // or "-","*","/","^","%"
var sum = DoTheCSharpOperation(Operator, ResultA.Value, ResultB.Value)
var sumResult = new Result(sum);
  • 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-25T12:43:40+00:00Added an answer on May 25, 2026 at 12:43 pm

    This sounds to me like a perfect application for the “dynamic” keyword:

    using System;
    using System.Diagnostics;
    
    namespace ConsoleApplication33 {
      public static class Program {
        private static void Main() {
          var result1=DoTheCSharpOperation(Operator.Plus, 1.2, 2.4);
          var result2=DoTheCSharpOperation(Operator.Plus, "Hello", 2.4);
          var result3=DoTheCSharpOperation(Operator.Minus, 5, 2); 
    
          Debug.WriteLine(result1); //a double with value 3.6
          Debug.WriteLine(result2); //a string with value "Hello2.4"
          Debug.WriteLine(result3); //an int with value 3
        }
    
        public enum Operator {
          Plus,
          Minus
        }
    
        public static object DoTheCSharpOperation(Operator op, dynamic a, dynamic b) {
          switch(op) {
            case Operator.Plus:
              return a+b;
            case Operator.Minus:
              return a-b;
            default:
              throw new Exception("unknown operator "+op);
          }
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write an android application that can parse files. I have figured
We have an application that parses tweets and we want to see the activity
I have a single Android application that houses a suite of applications. I want
I want to make an Application that uses RxTx version 2.2pre2 to work with
I want to develop an application that does a bunch of cool stuff. The
i want to develop an application that take email and password of facebook as
I want to create an application that doesn't use Portrait mode. I am not
I want to create an application that performs a particular action when the device
I want to write an application that monitors a music player. In my app
I want to develop an application that would extract the following things from an

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.