April 26, 2005

An Efficient Method of String Concatenation

A good way to concatenate strings in a loop or when performing multiple concatenations, is to use the StringBuilder class: String s = “a”s+=”b”; //this is slowStringBuilder sb = new StringBuilder();sb.Append(“a”);sb.Append(“b”);

Converting One Class Type to a Different Class Type

There are two ways to convert the objects between two different class types. Define a constructor in the target class, which takes an argument from the source class type: class source; // forward declarationclass target{ public : target():m_str(“WebSite”) {} target (const source& src); string m_str;};class source{ public: source () :

Get All Locales Supported by the Java Runtime

This code segment returns all the locales supported by the Java Runtime: // ListSupportedLocales.javaimport java.util.*;// other code to go here.Locale[] localeList = Locale.getAvailableLocales( ); for (int i=0; i

Access GridView Container Row Items from the Button Click Event

Assume Each GridViewRow contains Field1, Field2,…. Button: . . . To access the other items in the same row from inside the button click event, you need to find the corresponding GridViewRow in which the button is placed. GridViewRow grdRow = (GridViewRow)Button1.Parent.Parent; void Button1_Click(object o, EventArgs e) { Button Button1

Add Virtualization to Your Development Toolbox

t’s time again to open up your developer’s toolbox and make room for the new must-have tool, virtual machines. As a software consultant, I find myself traveling from customer to customer and constantly working in new development environments. As interesting as that is, a new environment means installing and configuring