Click here to Skip to main content
15,890,185 members
Home / Discussions / C#
   

C#

 
GeneralJumping off a cliff Pin
Tristan Rhodes16-Mar-04 3:14
Tristan Rhodes16-Mar-04 3:14 
GeneralRe: Jumping off a cliff Pin
Heath Stewart16-Mar-04 3:48
protectorHeath Stewart16-Mar-04 3:48 
GeneralRe: Jumping off a cliff Pin
Tristan Rhodes16-Mar-04 4:06
Tristan Rhodes16-Mar-04 4:06 
GeneralTreeview structure in datagrid Pin
Inpreet Singh16-Mar-04 0:38
Inpreet Singh16-Mar-04 0:38 
GeneralRe: Treeview structure in datagrid Pin
Heath Stewart16-Mar-04 3:43
protectorHeath Stewart16-Mar-04 3:43 
GeneralRe: Treeview structure in datagrid Pin
Anonymous16-Mar-04 17:52
Anonymous16-Mar-04 17:52 
GeneralUsing Resource file for collection of strings Pin
Inpreet Singh16-Mar-04 0:32
Inpreet Singh16-Mar-04 0:32 
GeneralRe: Using Resource file for collection of strings Pin
Heath Stewart16-Mar-04 3:42
protectorHeath Stewart16-Mar-04 3:42 
If you're talking about ResX files (or even .txt files can be used), you should see Resources in Applications[^] in the .NET Framework.

In VS.NET, this is pretty easy. With each form or control, VS.NET creates a hidden .resx file with the same name (only .cs.resx instead of .cs). If you click the "Show Hidden Files" button when your project is selected, you can see and edit these. They will be compiled into .resources files automatically. You can easily reference these in your class using something like:
ResourceManager resources = new ResourceManager(this.GetType());
...where this is an instance of your class. There's other overloads for the constructor as well. Note that the ResourceManager will be instantiated for each instance of each class that uses it.

A better way is often to have a single class that has an associated ResX file and use a singleton pattern. This is common in all the .NET FCL assemblies and I and others I've seen use this in larger applications as well.

If you're building your project using the SDK and the command line, you use the resgen.exe utility to compile a .txt or .resx file into a .resources file with the fully-qualified name of the Type to which you want to associate it (btw, it doesn't have to be associated with a Type), such as MyNamespace.MyClass.resources to be associated with a Type MyNamespace.MyClass. When you compile these, you include all the .resources files as embedded resources (using the /res switch on csc.exe).

Read that section on resources in applications, though, and you should get a better idea.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: Using Resource file for collection of strings Pin
Inpreet Singh16-Mar-04 23:17
Inpreet Singh16-Mar-04 23:17 
GeneralRe: Using Resource file for collection of strings Pin
Heath Stewart17-Mar-04 3:26
protectorHeath Stewart17-Mar-04 3:26 
QuestionWindows Service + ASP.NET, HOW? Pin
Johnny_B15-Mar-04 23:18
Johnny_B15-Mar-04 23:18 
AnswerRe: Windows Service + ASP.NET, HOW? Pin
Heath Stewart16-Mar-04 3:35
protectorHeath Stewart16-Mar-04 3:35 
GeneralRe: Windows Service + ASP.NET, HOW? Pin
Werdna16-Mar-04 4:02
Werdna16-Mar-04 4:02 
GeneralRe: Windows Service + ASP.NET, HOW? Pin
Heath Stewart16-Mar-04 4:15
protectorHeath Stewart16-Mar-04 4:15 
GeneralRe: Windows Service + ASP.NET, HOW? Pin
Johnny_B16-Mar-04 13:11
Johnny_B16-Mar-04 13:11 
GeneralRe: Windows Service + ASP.NET, HOW? Pin
Heath Stewart17-Mar-04 4:58
protectorHeath Stewart17-Mar-04 4:58 
QuestionHow to read records of a file of dbf in c# ? Pin
Solaer15-Mar-04 23:06
Solaer15-Mar-04 23:06 
Generalmain []args parameter to run another instance Pin
hazzem elrefai15-Mar-04 22:57
hazzem elrefai15-Mar-04 22:57 
GeneralRe: main []args parameter to run another instance Pin
hazzem elrefai16-Mar-04 1:41
hazzem elrefai16-Mar-04 1:41 
GeneralDrag and Drop feature in TreeView Pin
viru15-Mar-04 21:04
viru15-Mar-04 21:04 
GeneralRe: Drag and Drop feature in TreeView Pin
Heath Stewart16-Mar-04 3:23
protectorHeath Stewart16-Mar-04 3:23 
GeneralWeb control questions Pin
Den2Fly15-Mar-04 19:55
Den2Fly15-Mar-04 19:55 
GeneralRe: Web control questions Pin
Heath Stewart16-Mar-04 3:19
protectorHeath Stewart16-Mar-04 3:19 
GeneralRe: Web control questions Pin
Den2Fly16-Mar-04 3:44
Den2Fly16-Mar-04 3:44 
GeneralRe: Web control questions Pin
Heath Stewart16-Mar-04 3:53
protectorHeath Stewart16-Mar-04 3:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.