Is there anything like Javascript Eval in C# or Java [duplicate]

<strong>Possible Duplicate:</strong> using eval in Java

In javascript i can call a function using eval like :


Is there anything like that in C# or JAVA which lets me run C# or JAVA code?

String time = Eval("My csharp code");

Or Am I completely off the track?



Maybe you can use something like this: http://www.codeproject.com/Articles/11939/Evaluate-C-Code-Eval-Function


Maybe you can use something like this: http://rsudhakar.wordpress.com/2010/11/03/eval-in-java/




You can use Beanshell in Java. This produces a scripting library for Java and is used in many debuggers for ad hoc expressions.

However, use of "eval" or dynamic code is discouraged in Java (and I suspect most languages it's not a good idea)


There is no direct analogue - there is no built in function that will take a string and run it as executable code.

You can use the different reflection options of either platform to execute code dynamically. These include creating classes in code, compiling them and executing them and is not easy or fast.


  • JMeter - Set a dynamic variable for Loop Controller
  • JMeter - Verify a Specific Cookie Value was Used?
  • Jmeter : upload excel, hard coded values
  • Fetching json response in jmeter using beanshell
  • JMeter - do not pass post value in post data if null
  • How to replace white character by character using bean shell in Jmeter?
  • How to compare two different JSON response structure in java?
  • C# Accessing Excel Worksheet
  • How to hardcode the value in JMeter
  • WatiN generates empty pages
  • C Inline assembly - Operand type mismatch for 'fst'
  • Winform Designer Application
  • ASP Net Core - Mixing External Identity Provider with Individual User Accounts for Audit Tracking
  • Change color of row programmatically in WatchKit
  • Can I call custom javascript from an R jupyter notebook
  • Group variable in cobol
  • 'include' of functions in groovy scripts
  • How to replace TouchesBegan with UIGestureRecognizer
  • Using an enum contained in a Cloud Endpoint model on a Android client
  • Stitching 2 images (OpenCV)
  • Many to Many in Linq using Dapper
  • What's the name of this finding square root algorithm?
  • Android device acting as an accessory
  • Is there some graphical way to create my own configuration file on SonarLint?
  • Possible to get mouse events fired when cursor is outside page?
  • Cast between interfaces whose interface signatures are same
  • How to create a file in java without a extension
  • OpenGL ES texture problem, 4 duplicate columns and horizontal lines (Android)
  • ilmerge with a PFX file
  • QLineEdit password safety
  • Optimizing database types to compact database (SQLite)
  • Cross-Platform Protobuf Serialization
  • Do I've to free mysql result after storing it?
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • How to format a variable of double type
  • bootstrap to use multiple ng-app
  • How to get icons for entities from eclipse?
  • coudnt use logback because of log4j
  • Turn off referential integrity in Derby? is it possible?
  • JaxB to read class hierarchy