Thursday, February 21, 2013

linq to excel


How to get data from excel using linq in c#.

var excel = new ExcelQueryFactory("excelFileName");
var indianaCompanies = from c in excel.Worksheet<Company>()
                       where c.State == "IN"
                       select c;

For more information about this demo Clickhere  





Split in C#


Return type of split  method is an array[].

General syntax : 

         StringName.Split( '(' );
Here it will seperate the string by ' ( '.

We can also use multiple parameters.

For Example: 


We have a string   a=India(IND) is my country

a= a.Split( '(' , ')' )[1];

      Now, a= IND It seperates by two unicode seperators.[ ( , ) ].

For, a= a.Split( '(' , ')' )[0];
 It will return , a= 'India'.