Archives for the 'C#' Category

Coding against the DB

If you have to embed SQL in your code, this is how to do it in C#.
Highlights:

the using statement, which is like try-finally
@-quoted string literals
Parameters.AddWithValue(parameterName, value) (new in .NET Framework 2.0)

Coming from an ASP/PHP-MySQL background, it's great to not have to escape special SQL characters or to enclose varchar values within single quotes.
PLAIN TEXT
C#:

using System.Data;

using [...]

6 June 2007 | .NET, Software engineering, C# | No Comments

Polymorphism Explained

Polymorphism is the ability of an object to represent more than one type.
The MSDN Library explains polymorphism quite well. Emphasis mine.
PLAIN TEXT
C#:

public class A

{

    // code

}

 

public class B : A

{

    // code

}

"In the example above, class B is effectively both B and A. When you access a B object, you can use [...]

5 June 2007 | .NET, Software engineering, C# | No Comments

Comparative Overview of C#

I came across a clear and balanced overview of C# that pits it against C++ and Java. Do note that it was written just after Microsoft released .NET Framework 1.0, so it doesn't cover generics and anonymous methods. It's still good, though, as almost every point is illuminated by concise yet intuitive example code.

1 June 2007 | .NET, Software engineering, C# | No Comments

Hello C# World

I have decided to specialize in C#, believing that it will bring me higher pay and a better career path. My background is a mishmash of VB6, ASP, PHP, and .NET (both VB and C#). Due to certain circumstances, I didn't manage to get on the Java boat.
My perception of employers' perception is that ASP [...]

1 June 2007 | .NET, Software engineering, C# | No Comments

Database-Driven Multilingual Crystal Reports

I wrote some code that parses Crystal Reports text objects and translates them to another language. It reads from a Hashtable which may be populated from a database, a text file or an XML document. The code doesn't care about the names of the text objects, just their contents.
You may have to use the String.Trim() [...]

29 May 2007 | .NET, Software engineering, Crystal Reports, C# | No Comments