C# tutorial

Learn C# Day by Day with Real Word Examples

LATEST ARTICLES

How to troubleshoot MSAccess OleDb under Windows 7 64 bits

How to troubleshoot MSAccess OleDb under Windows 7 64 bits
If you had a C# application with MS Access Database that did compile under Vista 32 bits you may be surprise to discover that your program doesn't work any more with this connection string in app.config: You bought a brand new PC with Windows 7 64 bits and bad surprise when ...more»
26 Dec by admin in DataStructure

Use Strongly-Typed (Generics) Dictionary Data Structure instead of Hash Table to lookup Constants

Use Strongly-Typed (Generics) Dictionary Data Structure instead of Hash Table to lookup Constants
Let's say you're building a Quiz and need to associate Countries and their Capital. Instead of using a loosely-typed hashtable, you can use a Generics form available since .NET 2.0 which is Dictionary to get the benefit of strong-typed variables. Moreover to get the value of the associated key the ...more»
29 Nov by admin in ADO.NET

How to change a DataColumn Type in .NET/C#

How to change a DataColumn Type in .NET/C#
In some situations, you may need to change the DataColumn type of a DataTable. You can easily do so when the DataTable is empty. On the contrary, you are stuck! Fortunately in that case there is a way, albeit a circonvoluted one: clone the DataTable schema, change the type ...more»
29 Nov by admin in ADO.NET

How to create a DataSet with DataRelations Programmatically

How to create a DataSet with DataRelations Programmatically
Previously we've seen how to create a DataTable programmatically. But it is also possible to create a full DataSet with DataRelations Programmatically. Here's how: MSDN References: DataRelation Class DataRow.GetParentRows DataRow.GetChildRows ...more»
27 Nov by admin in DateTime

How to convert String to DateTime and DateTime to String

How to convert String to DateTime and DateTime to String
Converting from String to DateTime is not a trivial task as it requires some parsing. Fortunately .NET provides the DateTime.ParseExact method. Example: will output If one needs to convert this dateTime to a custom format like "dd.MM.YY" one would use the DateTime.ToString method: Output: ...more»
27 Nov by admin in ADO.NET

How to export a dataTable to a text file the easy way (using ODBC or Jet Engine)

How to export a dataTable to a text file the easy way (using ODBC or Jet Engine)
I have seen people struggling to export data in text format. Doing so in csv file format is relatively easy but some systems require fixed file format so here's how to do it the most easy way as I wished did find such tutorial myself when I did have that ...more»
27 Nov by admin in ADO.NET

How to create a DataTable programmatically

How to create a DataTable programmatically
Since .NET 2.0 it is possible to create a DataTable without creating a DataSet. To create a mere DataTable DataTable, you just logically need to first create the DataTable object: Then you have to create a new DataColumn and add it to the dataTable.Columns collection: You can specify a name and a ...more»
24 Oct by admin in OOP

Understanding C# delegates and events (part 1)

Understanding C# delegates and events (part 1)
What is a delegate ? According to MSDN: A delegate is a type that references a method. Once a delegate is assigned a method, it behaves exactly like that method. Any method that matches the delegate's signature, which consists of the return type and parameters, can be assigned to the delegate. In short, ...more»
17 Oct by admin in Beginner, Building

Mastering the C# Compiler

Mastering the C# Compiler
Visual Studio Express Edition is a blessing gift from Microsoft for C# Beginners. But the best way to really master a new programming language is to learn from scratch using a simple programmer's notepad. Also if you want to automate your builds with or without NAnt/MSBuild, you'd better know how ...more»