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

  • Home
  • SEARCH
  • 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 8507333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:50:31+00:00 2026-06-11T02:50:31+00:00

I am looking at creating a small interpreter for C# that I could load

  • 0

I am looking at creating a small interpreter for C# that I could load in some applications. Something that could be able to run things like this:

 > var arr = new[] { 1.5,2.0 };
                                 arr = { 1.5, 2.0 }
 > var sum = arr.Sum();
                                 sum = 3.5

And so I was thinking this could be achieved by creating a dictionary of all the variables and their types and then compile each of the row as they come, and then execute the function, get the result and stick it in the dictionary of variables.

However, it seems to me that this may be actually quite difficult to build and possibly very inefficient.

Then I thought that Powershell was doing what I needed. But how is it done? Can anyone enlighten me as to how Powershell works or what a good way would be to build a .Net interpreter?

  • 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-11T02:50:32+00:00Added an answer on June 11, 2026 at 2:50 am

    How about you host the PowerShell engine in your application and let it do the interpreting for you? For example:

    private static void Main(string[] args)
    {
      // Call the PowerShell.Create() method to create an 
      // empty pipeline.
      PowerShell ps = PowerShell.Create();
    
      // Call the PowerShell.AddScript(string) method to add 
      // some PowerShell script to execute.
      ps.AddScript("$arr = 1.5,2.0"); # Execute each line read from prompt
    
      // Call the PowerShell.Invoke() method to run the 
      // commands of the pipeline.
      foreach (PSObject result in ps.Invoke())
      {
        Console.WriteLine(result.ToString());
      } 
    } 
    

    If your goal is to learn how to build an interpreter, have a look at the interpreter pattern.

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

Sidebar

Related Questions

My project is creating a font (or something that I can use somewhat like
I'm looking at creating a sweepstake generator and to do this am only using
I am looking into creating type-safe generic controls. This is targeting the (reduced) generics
I was looking at creating a TRIGGER that will set the value of a
I am creating an actionbar with custom looking buttons that I put in the
Creating a Lisp syntax like DSL - very small specific application - but very
I am looking for an extremely small way of turning a string like 123
Just looking for some opinions/ideas on how best to do this. I'm building an
I am creating a small project that heavily relies on JavaScript. I come from
I am looking at creating a small class generator for a project. I have

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.