Tuesday, June 30, 2009

Find Average from datatable column using LINQ and Compute Method

--Using LINQ

var v = (from o in dt.Rows.Cast()
select o.Field("Grand Total")).Average();

--Using Datatable Compute Method

Object objAvg;
objAvg = dt.Compute("Avg([Grand Total])", "[Grand Total] > 0");

--Find Standard Deviation using Datatable Compute method

Object objStDev;
objStDev = dt.Compute("StDev([Grand Total])", "[Grand Total] > 0");

Thursday, June 11, 2009

Regualr expressions for password

Regular expression for Password must be 8 or more characters long, including a capital letter and a number or symbol.

^.*(?=.{8,})(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=\d]).*$


Regular expression for Password must be 8 or more characters long, including a capital letter and a number and symbol.

^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$


Like wise you can create your own Regular expression.