Browse by Tags

All Tags » C# (RSS)

Back to Basic: C# Using statement, Return and IDisposable

In day to day coding, I found myself using a lot of disposable objects like DbConnection, Font, etc. And so, naturally, putting this code block inside a using statement is common sense. In theory, I know that when you use a using block in your code, your...
Posted by Jimmy Chandra | with no comments
Filed under: , , ,

Back to Basic: Debug.Assert(...)

I wonder how many of us litter our code with this particular line? How do you use them? Do you know what you need to watch out when you do use them? Is it necessary to put this line of code in our code? What is the consequence of putting this line into...
Posted by Jimmy Chandra | 1 comment(s)
Filed under: , ,

Detecting If a Number has a Decimal Fraction

This seems like pretty basic functionality of a number type, but I can't seem to be able to find any built-in function in any of .Net number type that support decimal (decimal, double) or the System.Math class to do this. In any case, if you find...
Posted by Jimmy Chandra | 5 comment(s)
Filed under: ,

On Activator.CreateInstance...

When you use .NET Activator.CreateInstance to create a new object of a certain type, make sure you reference the Project / DLL that contain the type definition or load it manually somehow to an AppDomain . Otherwise your call will fail. Say you have the...
Posted by Jimmy Chandra | with no comments
Filed under: ,

Playing Around with Anonymous Type, Extension Method, LINQ, and Generic

I was reading this particular entry from AlexJ's blog, in which he discussed how to use anonymous type returned from one function in another function. I strongly recommend you read it first before reading any further. Basically, most people would...

Preview of C# version 3.0 features

Wow, C# 2.0 is not officially out of the door, C# 3.0 is already rearing its head :). In this post I'll go through some of the new features of the 3.0 version of C#. Feature 1: Implicitly typed local variables. Variable declaration has become simpler...
Posted by Jimmy Chandra | with no comments
Filed under: , , ,

Neat Partially Partial C# 2.0 Keyword

Partial is great! The new Partial keyword in C# 2.0 is a excellent addition to the language. What does it do? It allows you to create an extension to an existing class (as long as the original class is also marked Partial) without having to mess around...
Posted by Jimmy Chandra | 1 comment(s)
Filed under: , ,