本文整理汇总了C#中System.Data.DataTable.Compute方法的典型用法代码示例。如果您正苦于以下问题:C# System.Data.DataTable.Compute方法的具体用法?C# System.Data.DataTable.Compute怎么用?C# System.Data.DataTable.Compute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.DataTable
的用法示例。
在下文中一共展示了System.Data.DataTable.Compute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetResult
protected void GetResult(object sender, DirectEventArgs e)
{
if ((First.Text == "0") || (Second.Text == "0") || (Third.Text == "0"))
{
X.Msg.Alert("Uwaga!", "Podaj inna wartość niż 0").Show();
}
else if (First.Text.IsEmpty() || Second.Text.IsEmpty() || Third.Text.IsEmpty() || Operator1.Text.IsEmpty() || Operator2.Text.IsEmpty())
{
X.Msg.Alert("Uwaga!", "Wypełnij wszystkie pola").Show();
}
else
{
var dt = new System.Data.DataTable();
wynik.Text = (dt.Compute(First.Text + Operator1.Text + Second.Text + Operator2.Text + Third.Text, "")).ToString();
Store2.Add(new {First = First.Text, Operator1 = Operator1.Text, Second = Second.Text,Operator2 = Operator2.Text,
Third = Third.Text, data = DateTime.Now.ToString("yyyy-MM-dd h:mm"), wynik = wynik.Text });
}
}
示例2: Formula
public static float[,] Formula(string formula)
{
string[] formulaPreview = formula.Split('|');
int _i = Convert.ToInt32(formulaPreview[0]);
int _j = Convert.ToInt32(formulaPreview[1]);
var formulaCalculator = new System.Data.DataTable();
float[,] _matrix = new float[_i, _j];
for (int i = 0; i < _i; i++) {
for (int j = 0; j < _j; j++) {
string i_formula = formulaPreview[2].Replace("i", (i + 1).ToString());
string x_formula = formulaPreview[3].Replace("j", (j + 1).ToString());
Console.WriteLine(i_formula);
_matrix[i, j] = Convert.ToSingle(formulaCalculator.Compute("(" + i_formula + " + " + x_formula + ")", ""));
}
}
return _matrix;
}