Description
In this program I written code snippet for How to use resource (resx) in C#.Net Coding. Here I added some resource file with multilingual. Used Assemblies and Resource Manager for construct the coding.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using System.Resources;
using System.Globalization;
namespace MultiLingual
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
CultureInfo ci = new CultureInfo("ta-IN");
Assembly a = Assembly.Load("MultiLingual");
ResourceManager rm = new ResourceManager("MultiLingual.Lang.langres.tam", a);
label1.Text = rm.GetString("fname",ci);
label2.Text = rm.GetString("lname",ci);
button2.Text = rm.GetString("btnname", ci);
}
private void button1_Click(object sender, EventArgs e)
{
CultureInfo ci = new CultureInfo("en-US");
Assembly a = Assembly.Load("MultiLingual");
ResourceManager rm = new ResourceManager("MultiLingual.Lang.langres", a);
label1.Text = rm.GetString("fname", ci);
label2.Text = rm.GetString("lname", ci);
button1.Text = rm.GetString("btnname", ci);
}
private void button3_Click(object sender, EventArgs e)
{
Assembly a = Assembly.Load("MultiLingual");
ResourceManager rm = new ResourceManager("MultiLingual.Lang.langres.mal", a);
label1.Text = rm.GetString("fname");
label2.Text = rm.GetString("lname");
button3.Text = rm.GetString("btnname");
}
}
}