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
  1. Home
  2. General Programming
  3. C#
  4. how to convert string into code?

how to convert string into code?

Scheduled Pinned Locked Moved C#
csharptutorialquestion
10 Posts 4 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.
  • R Offline
    R Offline
    rachelicohen
    wrote on last edited by
    #1

    I am prigramming a new "language" o programming The user writes in the new "language" and then I translate it into c# the translation is a string how do the sing becomes a code that can be executed? :)

    L S 2 Replies Last reply
    0
    • R rachelicohen

      I am prigramming a new "language" o programming The user writes in the new "language" and then I translate it into c# the translation is a string how do the sing becomes a code that can be executed? :)

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      It needs to be compiled. C# is not a scripting language [^]

      R 1 Reply Last reply
      0
      • L Lost User

        It needs to be compiled. C# is not a scripting language [^]

        R Offline
        R Offline
        rachelicohen
        wrote on last edited by
        #3

        there must be a way to do this! for example: textbox1.text="button1.backcolor=system.drawing.color.red" how will it become red???

        L 1 Reply Last reply
        0
        • R rachelicohen

          I am prigramming a new "language" o programming The user writes in the new "language" and then I translate it into c# the translation is a string how do the sing becomes a code that can be executed? :)

          S Offline
          S Offline
          SimpleData
          wrote on last edited by
          #4

          I think you can take the text that user written in your new language and translate into C#, then write it to a .cs file and compile it with csc.exe. CSharp Compiler is available in every machine which has .NET Framework installed in it. And of course user will have .NET Framework installed. OR You can use Microsoft.CSharp.CSharpCodeProvider to compile and run code in real-time. Run-Time Code Generation I: Compile C#-Code using Microsoft.CSharp and System.CodeCom.Compiler[^]

          R 1 Reply Last reply
          0
          • S SimpleData

            I think you can take the text that user written in your new language and translate into C#, then write it to a .cs file and compile it with csc.exe. CSharp Compiler is available in every machine which has .NET Framework installed in it. And of course user will have .NET Framework installed. OR You can use Microsoft.CSharp.CSharpCodeProvider to compile and run code in real-time. Run-Time Code Generation I: Compile C#-Code using Microsoft.CSharp and System.CodeCom.Compiler[^]

            R Offline
            R Offline
            rachelicohen
            wrote on last edited by
            #5

            this program in the link is not running. o I can not relly understand and I need to know it in "emergency" is there any ggod example?

            S 1 Reply Last reply
            0
            • R rachelicohen

              this program in the link is not running. o I can not relly understand and I need to know it in "emergency" is there any ggod example?

              S Offline
              S Offline
              SimpleData
              wrote on last edited by
              #6

              I tried it now and I couldn't get it worked too. But I will try some more, if it works I will let you know.

              R 1 Reply Last reply
              0
              • S SimpleData

                I tried it now and I couldn't get it worked too. But I will try some more, if it works I will let you know.

                R Offline
                R Offline
                rachelicohen
                wrote on last edited by
                #7

                Thank you! I apiciate and hope!

                S 1 Reply Last reply
                0
                • R rachelicohen

                  Thank you! I apiciate and hope!

                  S Offline
                  S Offline
                  SimpleData
                  wrote on last edited by
                  #8

                  I researched about this topic a little and written a program which is I think enough for you to understand how CodeProvider works. Just run the project and enter

                  using System;
                  using System.Collections.Generic;
                  using System.Text;

                  namespace ConsoleApplication1
                  {
                  class Program
                  {
                  static void Main(string[] args)
                  {
                  Console.WriteLine("IS IT WORKING!!");
                  Console.ReadLine();
                  }
                  }
                  }

                  to the textbox. Then press Generate. The compiled executable will be in the same direcory as your program is, as "product.exe" http://rapidshare.com/files/227199842/RealTime_Csharp_Code_Compiler.rar[^] Let me know what you think.

                  R 1 Reply Last reply
                  0
                  • S SimpleData

                    I researched about this topic a little and written a program which is I think enough for you to understand how CodeProvider works. Just run the project and enter

                    using System;
                    using System.Collections.Generic;
                    using System.Text;

                    namespace ConsoleApplication1
                    {
                    class Program
                    {
                    static void Main(string[] args)
                    {
                    Console.WriteLine("IS IT WORKING!!");
                    Console.ReadLine();
                    }
                    }
                    }

                    to the textbox. Then press Generate. The compiled executable will be in the same direcory as your program is, as "product.exe" http://rapidshare.com/files/227199842/RealTime_Csharp_Code_Compiler.rar[^] Let me know what you think.

                    R Offline
                    R Offline
                    Rolando CC
                    wrote on last edited by
                    #9

                    It works for me! :-\

                    1 Reply Last reply
                    0
                    • R rachelicohen

                      there must be a way to do this! for example: textbox1.text="button1.backcolor=system.drawing.color.red" how will it become red???

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      Use a struct that would essentially be a look up table.

                      struct ColorStruct
                      {
                      public Color setColor

                      public ColorStruct(string input)
                      {
                      switch(input){
                      case "system.drawing.color.red"
                      setColor = Color.red
                      break;
                      ...
                      ...
                      ...
                      }
                      }
                      }

                      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