Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. executing a STRING formula???

executing a STRING formula???

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelpquestion
8 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Karan_TN
    wrote on last edited by
    #1

    Hi... currently i m using asp.net 2.0 (With C#) i m having an formula in my string as "(((5+6+4)/15)*100))" i would like to execute this string and get the resultant as integer. Help me ... - Karan

    J 1 2 Replies Last reply
    0
    • K Karan_TN

      Hi... currently i m using asp.net 2.0 (With C#) i m having an formula in my string as "(((5+6+4)/15)*100))" i would like to execute this string and get the resultant as integer. Help me ... - Karan

      J Offline
      J Offline
      J4amieC
      wrote on last edited by
      #2

      HAve a look through this[^] list of articles. This one[^] looks to do what you want. As does this one[^].

      1 Reply Last reply
      0
      • K Karan_TN

        Hi... currently i m using asp.net 2.0 (With C#) i m having an formula in my string as "(((5+6+4)/15)*100))" i would like to execute this string and get the resultant as integer. Help me ... - Karan

        1 Offline
        1 Offline
        11Developer
        wrote on last edited by
        #3

        first convert the string into integer by Convert.ToInt32 then perform calculations

        A 1 Reply Last reply
        0
        • 1 11Developer

          first convert the string into integer by Convert.ToInt32 then perform calculations

          A Offline
          A Offline
          Abhijit Jana
          wrote on last edited by
          #4

          11Developer wrote:

          first convert the string into integer by Convert.ToInt32 then perform calculations

          How will you convert this string "(((5+6+4)/15)*100))" as interger ? Did you check the answer of J4amieC ?

          Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Visit My Latest Article : Beginner's Guide : Exploring IIS 6.0 With ASP.NET

          1 A 2 Replies Last reply
          0
          • A Abhijit Jana

            11Developer wrote:

            first convert the string into integer by Convert.ToInt32 then perform calculations

            How will you convert this string "(((5+6+4)/15)*100))" as interger ? Did you check the answer of J4amieC ?

            Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Visit My Latest Article : Beginner's Guide : Exploring IIS 6.0 With ASP.NET

            1 Offline
            1 Offline
            11Developer
            wrote on last edited by
            #5

            If d string is fixed then one can use like this string s = "(((5+6+4)/15)*100)"; int int1 = Convert.ToInt32(s.Substring(3, 1)); int int2 = Convert.ToInt32(s.Substring(5, 1)); int int3 = Convert.ToInt32(s.Substring(7, 1)); int int4 = Convert.ToInt32(s.Substring(10, 2)); int int5 = Convert.ToInt32(s.Substring(14, 3)); int ans = (((int1+int2+int3)/int4)*int5);

            S A 2 Replies Last reply
            0
            • A Abhijit Jana

              11Developer wrote:

              first convert the string into integer by Convert.ToInt32 then perform calculations

              How will you convert this string "(((5+6+4)/15)*100))" as interger ? Did you check the answer of J4amieC ?

              Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Visit My Latest Article : Beginner's Guide : Exploring IIS 6.0 With ASP.NET

              A Offline
              A Offline
              Abhishek Sur
              wrote on last edited by
              #6

              Ya .. Infix to Postfix is the only option.. . :-D :-D

              Abhishek Sur


              My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

              **Don't forget to click "Good Answer" if you like to.

              1 Reply Last reply
              0
              • 1 11Developer

                If d string is fixed then one can use like this string s = "(((5+6+4)/15)*100)"; int int1 = Convert.ToInt32(s.Substring(3, 1)); int int2 = Convert.ToInt32(s.Substring(5, 1)); int int3 = Convert.ToInt32(s.Substring(7, 1)); int int4 = Convert.ToInt32(s.Substring(10, 2)); int int5 = Convert.ToInt32(s.Substring(14, 3)); int ans = (((int1+int2+int3)/int4)*int5);

                S Offline
                S Offline
                saini arun
                wrote on last edited by
                #7

                That's great!! I wonder if you can write the same logic for... string s = "(((15+16+14)/115)*1100)"; and what about string s = "(((-5+6+4)/15)*100)"; :)

                1 Reply Last reply
                0
                • 1 11Developer

                  If d string is fixed then one can use like this string s = "(((5+6+4)/15)*100)"; int int1 = Convert.ToInt32(s.Substring(3, 1)); int int2 = Convert.ToInt32(s.Substring(5, 1)); int int3 = Convert.ToInt32(s.Substring(7, 1)); int int4 = Convert.ToInt32(s.Substring(10, 2)); int int5 = Convert.ToInt32(s.Substring(14, 3)); int ans = (((int1+int2+int3)/int4)*int5);

                  A Offline
                  A Offline
                  Abhijit Jana
                  wrote on last edited by
                  #8

                  11Developer wrote:

                  If d string is fixed then one can use like this

                  This is not like that. This is an Infix string. First of all you need to convert into of PostFix or Prefix to perform the calculation as the computer does internally. For that you can simply use Data Structure like Stack or Tree.

                  Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Visit My Latest Article : Beginner's Guide : Exploring IIS 6.0 With ASP.NET

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups