If you're after a "pure" Microsoft solution you should check out Roslyn, once it ships. But until then you might want to take a look at the Fast Lightweight Expression Evaluator project on CodePlex:
Flee is an expression parser and evaluator for the .NET framework. It allows you to compute the value of string expressions such as sqrt(a^2 + b^2) at runtime. It uses a custom compiler, strongly-typed expression language, and lightweight codegen to compile expressions directly to IL. This means that expression evaluation is extremely fast and efficient. Try out the demo, which lets you generate images based on expressions, and see for yourself.
If that doesn't fit your bill you should check out the shameless self-promotion of my own project, below.
ExpressionEvaluator is a library to help developers evaluate C# and VB .NET expressions. The expressions you need to evaluate are compiled through the .NET Framework's own CodeDOM so nearly all language features are supported. The library can expose remotable objects to the expressions for a scripting-like capability. All expression evaluation is sandboxed.
Example
static void Main(string[] args)
{
var expressions = new List<string>
{
"3 * 5",
"Log10(50)",
"Parameters!Greeting + \" World!\""
};
// An ExpressionMeta contains the expressions and extensions to be compiled.
var meta = new ExpressionMeta("VisualBasic");
// Add the expressions to be compiled.
foreach(var expression in expressions)
meta.AddExpression(expression);
// Add the extensions to be compiled.
var extension = new Dictionary<string, string> {{"Greeting", "Hello"}};
meta.AddExtensionIgnoreAssembly(new Extension("Parameters", extension));
// Compile the expressions
using(var evaluator = meta.Compile())
{
// Evaluate the expression
foreach(var expression in expressions)
Console.WriteLine("{0}", evaluator.Evaluate(expression));
}
}
Output
15
1.69897000433602
Hello World!
System.Strings as methods.