Visual C#

LINQ to XML (C#) create new xml document

Posted by admin on April 10, 2008 at 5:14 pm

How to create a new xml with LINQ   var objCars= new[] { new {CarID = 2, CarName = "Ford", Fuel = "Diesel"}, new {CarID = 3, CarName = "Audi", Fuel = "Diesel"}, new {CarID = 4, CarName = "Mercedes", Fuel = "Diesel"}, new {CarID = 1, CarName = "BMW", Fuel = "Diesel"} };   [...]

Formatting C# strings

Posted by admin on March 28, 2008 at 11:02 am

  string s = String.Format("{{ hello to all }}"); Console.WriteLine(s);    //prints ‘{ hello to all }’   int i = 42; string s = String.Format("{0}", i);   //prints ’42′   int i = 42; string s = String.Format("{{{0}}}", i);   //prints ‘{42}’       int i = 42; string s = String.Format("{0:N}", i); [...]

LINQ to DataSet (C#)

Posted by admin on March 26, 2008 at 10:53 am

LINQ to DataSet Perform set operations on sequences of DataRow objects. Retrieve and set DataColumn values Obtain a LINQ standard IEnumerable sequence from a DataTable so Standard Query Operatorsmay be called. To use LINQ to Dataset include next namespaces using System.Data; using System.Linq; Step by Step Exemple: Starting with a simple class: class Student { [...]

.NET – LINQ in C#

Posted by admin on March 26, 2008 at 10:51 am

LINQ (Language integrated Query) string[] numbers = { "0042", "010", "9", "27" }; int[] nums = numbers.Select(s => Int32.Parse(s)).ToArray(); foreach (var num in nums) Console.WriteLine(num); What where LINQ is useful? LINQ to Objects – LINQ to XML – LINQ to SQL – LINQ to DataSet Perform set operations on sequences of DataRow objects. Retrieve and [...]

LINQ to SQL (C#)

Posted by admin on March 25, 2008 at 11:54 am

Startup for LINQ to SQL with C# This walkthrough requires the following: This walkthrough uses a dedicated folder (“c:\linqtest6″) to hold files. Create this folder before you begin the walkthrough. The Northwind sample database. If you do not have this database on your development computer, you can download it from the Microsoft download site. For [...]