ResourceSet

A ResourceSet, which is created by a ResourceManager, loads and caches all resources for a single culture. However, a ResourceSet does not provide fallback, so it is best suited for tools that work with specific locales and for applications that are not localized. The following three lines of code show a possible modification to WorldCalc.cs to use a ResourceSet rather than a ResourceManager.

private ResourceSet rs;
rs = rm.GetResourceSet(Thread.CurrentThread.CurrentUICulture, true, true); 
// Replace all occurrences of rm.GetString with rs.GetString.

Here is the Visual Basic equivalent from the Graphic.vb sample file:

Private rs As ResourceSet 
rs = rm.GetResourceSet(Thread.CurrentThread.CurrentUICulture, true, true)
' Replace all occurrences of rm.GetString with rs.GetString.

The first line simply declares a ResourceSet variable. The second line creates the ResourceSet from the ResourceManager, passing in the current culture. The second parameter controls whether the ResourceSet is created if it has not been loaded yet, and the third parameter controls whether parent CultureInfo objects should be loaded for resource inheritance. Both ResourceManager and ResourceSet implement the GetString method, and the third line illustrates the minor code changes required.

If you make the changes, recompile, and run the WorldCalc sample application on an English-language computer by using the following command-line:

WorldCalc de-CH

you end up with an application that looks like the following figure.