By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,896 Members | 1,983 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,896 IT Pros & Developers. It's quick & easy.

Resource File in console application

P: n/a
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

Sep 28 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

gopal wrote:
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 ();
}
}
}

Sep 28 '06 #2

P: n/a

gopal wrote:
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/

Sep 28 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.