September 26, 2009

Create an Interface from a Class in Visual Studio

Although it’s not considered best practice, after writing a class, sometimes you may decide that all or part of that class might work better as an interface. When that happens, Visual Studio IDE provides a helpful option. In the VS editor, right-click anywhere in the class and choose Refactor ?

Using String.split(String) vs. Using a StringTokenizer

Most programmers use the String.split(String) method to convert a String to a String array specifying a delimiter. However, I feel it’s unsafe to rely on the split() method in some cases, because it doesn’t always work properly. For example, sometimes after calling split() the first array index holds a space

Displaying Row Numbers in a DataGrid

To display row numbers in an ASP.NET DataGrid, first create a template column and set its ItemTemplate value using the following code:

Convert a Delimited String to a Generic List<string>

This function separates the items in the delimited string (parameter 1) at the delimiter (parameter 2), creates a new generic string list, and then adds each item to the new list. Finally, it returns the filled list. public static List ConvertStringsToStringList(string items, char separator){ List list = new List(); string[]

Define and Execute a Groovy Bean Inside a Spring Application Context

A quick example should suffice for defining and executing a Groovy Bean inside a Spring application context. Here’s a short Java interface: package com.springandgroovy; public interface HelloWorldService { String sayHello(); } And here’s the Groovy implementation: import com.springandgroovy.HelloWorldService; class HelloWorldServiceImpl implements HelloWorldService { String name String sayHello() { “Hello $name.

Executing Stored Procedures and Functions From PHP in Windows

tored procedures and functions are a new feature of MySQL 5.0. A stored procedure is a pre-built procedure containing one or more SQL statements stored in the database server. This article shows how to create a few basic stored procedure and function examples, and call MySQL stored procedures and functions