Field Access V/s Local Variable Performance

Jeffrey Richter has written a nice article on performance of Local variable V/s Field in a C# class. 

Localizing a Windows Form

Always have a question mark about how to do localization for a windows Form application. So taken this challenge and here the steps goes

1. Create a Windows Forms Project.

2. Set the Localizable property of Form to True.

3. A resx file is created per window form.

4. Add Control Name.Text as Name and its value to “My Form”. The convention of the name is Control Name.Property Name

5. A resource file generated per language i.e. if you would like to support 5 languages then need to have 5 resx file. Each one following MS specified naming convention.

6. Initializes the ResourceManager
ResourceManager resMgr = new ResourceManager(,
Here while providing the name of the form provide the fully qualified name of the form class name i.e. with namespace.

7. Initializes the Culture based on the language selected, assumming there is config file where the locale is set
locale = ConfigurationManager.AppSettings[“LOCALE”];
if (locale == “DEFAULT”)
Thread.CurrentThread.CurrentUICulture = CultureInfo.InstalledUICulture;
Thread.CurrentThread.CurrentUICulture = new CultureInfo(locale);

8. Now use the ResourceManager to read the read the corresponding culture string

this.Text = resMgr.GetString(“<Control Name>. <Property Name>”, Thread.CurrentThread.CurrentUICulture);
The above set the Text property of the Form to the corresponding localized string.

Yuppppieeeeeeeee the form is localized.

The namespaces to refer
using System.Threading;
using System.Globalization;
using System.Resources;

The Links for help
Link 1

Windows Form Life Cycle

A link to Windows Form Life Cycle

Retrieving Stored Procedures Parameter Info using ADO.NET

 The below code provides way to retrieve meta information about the stored procedure argument

//The usual code
OleDbConnection dbConnection = new OleDbConnection(<Connection string>);
OleDbCommand dbCommand = new OleDbCommand(<sp name>,dbConnection);
dbCommand.CommandType = CommandType.StoredProcedure;


The above static DeriveParameters method retrieve information about stored procedure specified by the command object.

//Iterating over the Parameter and retrieving the meta information….
foreach(OleDbParameter param in discoveredParameters)
Console.WriteLine(“Name Of Parameter:{0}”,param.ParameterName);
Console.WriteLine(“Data Type: {0}”,param.OleDbType.ToString());
Console.WriteLine(“Input/Input-Output: {0}”,param.Direction.ToString());