13. Resources

A RESOURCE IS A NAMED PIECE OF DATA that is bound to an assembly at build time.[1] Resources are an extremely useful way to bundle arbitrary data such as text, graphics, and sounds into your applications and components for use at run time in tasks as diverse as setting the background image on a form and setting the label of a button. And because applications and components can find themselves being used in countries other than those in which they were written, resources also serve as the building block for internationalization to support no-compile deployment of localized resources.

Resource Basics

Imagine setting the background image of a form by loading a bitmap from a file:

// MainForm.csnamespace ResourcesSample {  partial class MainForm : Form { ...

Get Windows Forms 2.0 Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.