Archive for the ‘.Net’ Category

C# Converting Time between TimeZones in C#

Thursday, October 2nd, 2008

.Net 3.5 has introduced a new TimeZoneInfo class which is an improvement over the existing TimeZone class. The TimeZone class can work on local TimeZone only i.e. converting between UTC and Local time zone only. The new TimeZoneInfo class provide much more richer functionality of working with different other Time zone’s.
(more…)

Get user IP address

Thursday, September 25th, 2008

Well, yes, it looks like trivial but it isn’t. Many a times we need to get the IP address of the user. There are a handful of suggestions to do this. I discuss the methods and the short comings in them.
(more…)

.Net Blocking websites

Sunday, July 27th, 2008

Think in the lines of Parental control application where we need to block certain websites from being accessed. To make it harder, this will be a Windows application where user can configure the sites to be blocked and unblocked.

Let’s start thinking of what we can do to achieve this.
(more…)

WPF Setting Grid row and column number for a control being added to Grid

Saturday, June 7th, 2008

In normal case we generally add our controls to the WPF Grid in XAML setting the Row and Column value. If you want to add a control to the Grid at runtime from Code-behind, the way to do it will be,

yourGrid.Children.Add(yourControl);

(more…)

C# Conditional breakpoints - Debugging a thread

Thursday, April 3rd, 2008

One of the cool feature of VS is the ability to set conditional breakpoints i.e. setting a breakpoints which hit based on a condition. When the condition is True the breakpoint will hit or else it won’t.
(more…)

WPF Timer

Wednesday, March 26th, 2008

This article discusses the WPF DispatcherTimer.

Most of us are from a background of C# (or VB.Net). You must have some point of time come across a scenario for performing a repetitive GUI operation after certain period of time. The solution in most cases has been the WinForm’s Timer.

What about WPF ? Does it have a Timer ?
(more…)

Find if database, table or stored procedure exists using C#

Saturday, February 23rd, 2008

There is a cool list of MetaData functions present in SQL server. I will be discussing one of them - object_id

Often we need to check if the Database is present and if it not then we need to create a new one. The most common answer to this is, try to connect to the Db and if the connection fails/throws an exception then the database does not exist. Do you think it is correct ?
(more…)

.Net Rounding to nearest 10

Wednesday, September 5th, 2007

The following code demonstrates how to round a number to the nearest 10 or 100 or 100 or etc..

(more…)