Thursday, July 21, 2011

StringBuilder Object where you can point specific character but not in System.String

From sample code, you will see nice thing that can be useful in programming
System.Text.StringBuilder sb = new System.Text.StringBuilder("Rat: the ideal pet");
sb.Append(" is caught");
sb[0] = 'C';
Output : Cat: the ideal pet is caught

Thursday, July 14, 2011

Padding character before a string in sql query

select right(replicate(@padchar, @len) + @str, @len)
e.g. select right(replicate('0', 10) + 'hell boy', 10)

Wednesday, July 13, 2011

Expression evaluation in C#

Try with this code block which is faster than using codeDom
static double Evaluate(string expression)
var loDataTable = new DataTable();
var loDataColumn = new DataColumn("Eval", typeof(double), expression);
return (double)(loDataTable.Rows[0]["Eval"]);