Resource File in console application

G

gopal

Hi I am a newbie and i am trying to create a resource file (resx) for a
console C# application
Can i go to current C# project and add a new resource file and then
start adding values?

Can anyone please show a sample console application having a resource
file added like this.

Help would be appreciated

Regards
JK
 
N

nick_nw

gopal said:
Hi I am a newbie and i am trying to create a resource file (resx) for a
console C# application
Can i go to current C# project and add a new resource file and then
start adding values?

Can anyone please show a sample console application having a resource
file added like this.

Help would be appreciated

Regards
JK

Add a resource file via Project -> Add New Item -> Assembly Resource
File

Add items to your resource file.

Example code to get a resource with a "name" of "Res1" from a resource
file:

using System;

namespace ConsoleApplication1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
System.Resources.ResourceManager rm = new
System.Resources.ResourceManager ("ConsoleApplication1.Resource1",
System.Reflection.Assembly.GetExecutingAssembly());
Console.WriteLine (rm.GetString ("Res1"));
Console.ReadLine ();
}
}
}
 
N

nick_nw

gopal said:
Hi I am a newbie and i am trying to create a resource file (resx) for a
console C# application
Can i go to current C# project and add a new resource file and then
start adding values?

Can anyone please show a sample console application having a resource
file added like this.

Help would be appreciated

Regards
JK

Add a resource file via Project -> Add New Item -> Assembly Resource
File

Add items to your resource file.

Example code to get a resource with a "name" of "Res1" from a resource
file:

using System;

namespace ConsoleApplication1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
System.Resources.ResourceManager rm = new
System.Resources.ResourceManager ("ConsoleApplication1.Resource1",
System.Reflection.Assembly.GetExecutingAssembly());
Console.WriteLine (rm.GetString ("Res1"));
Console.ReadLine ();
}
}
}

best

Nick
http://seecharp.blogspot.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top