Home > Net >  How do I use a string resource file?
How do I use a string resource file?

Time:01-20

I am using Visual Studio 2022 and I am struggling to figure out how to properly embed and use a resource file in order to use GetString().

teadates.txt:

DEC=December
MAR=March

Based on the enter image description here

Note that a teadates.Designer.cs file is now automatically added to the Solution Explorer.

  1. You can now access the string resources from code via for example teadates.DEC

enter image description here

Or access the resource manager:

internal class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(teadates.DEC);
        Console.WriteLine(teadates.ResourceManager.GetString("DEC"));
    }
}
  • Related