Evaluate Boolen expression using Compute Method of Data table in C#

Posted by Rajnilari2015 under C# category on | Points: 40 | Views : 215
Say we want to evaluate a boolean expression at runtime say True And True Or False. We can use

using System;
using System.Data;
namespace ConsoleApplication1

public class Program

public static void Main()

DataTable dt = new DataTable();
var result = dt.Compute("True And True Or False", "");

Comments or Responses

Posted by: Vishalneeraj-24503 on: 4/19/2016 Level:Platinum | Status: [Member] [MVP] | Points: 10
What will be the output of above expression and where should we use?
Posted by: Rajnilari2015 on: 4/19/2016 Level:Platinum | Status: [Member] [Microsoft_MVP] [MVP] | Points: 10
Well try out(: and it is useful for Business Rules Validation framework

Login to post response