Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道如何访问 Razor 中的资源:
@Resources.text.Description
但是我怎样才能做到这一点,在一个循环中,并动态引用资源名称?就像是:
@foreach (Data.Local in @Model.Locals) { <div>@Resources.text[@local.Name]</div> }
可能吗?
好的发现了一些技巧。在 Data.Local 类中,字段 Name 实际上是:
string resx = "Resources.text"; ResourceGetter.GetResourceFrom(resx, name);
名称是您想要的资源。