小编Tom*_*Tom的帖子

C#using语句应用程序范围

我有一个关于using多个文件的语句的问题.

我已经为我想在程序中使用的类创建了一个重载.为了在我的一个文件中这样做,我添加了以下using语句.

using ClassName = CustomClassName;
Run Code Online (Sandbox Code Playgroud)

这有效,但仅适用于该特定文件.

有没有办法让这个为我的整个项目工作?

c# using

4
推荐指数
2
解决办法
532
查看次数

字典<string,string> intellisense

有没有办法获得Dictionary<string,string>C#中所有键的intellisense ?

或者是否可以获得具有字符串参数的方法的intellisense.

我希望有类似的东西ResourceManager.GetString("").如果可能的话,我不想创建一个带有常量字符串的静态类来模拟它.

编辑:

我目前正在使用字典将多个资源文件合并到一个字典中,这样做是因为资源在多个项目中使用并且需要覆盖.

var temp = ResourceFile1.ResourceManager
                    .GetResourceSet(CultureInfo.CurrentUICulture, true, true)
                    .Cast<object>()
                    .Select(
                        x => new
                            {
                                ID = 1,
                                Value = x.GetType().GetProperty("Value").GetValue(x, null).ToString(),
                                Key = x.GetType().GetProperty("Key").GetValue(x, null).ToString()
                            });
                temp = temp.Concat(
                    ResourceFile2.ResourceManager
                        .GetResourceSet(CultureInfo.CurrentUICulture, true, true)
                        .Cast<object>()
                        .Select(
                            x => new
                            {
                                ID = 2,
                                Value = x.GetType().GetProperty("Value").GetValue(x, null).ToString(),
                                Key = x.GetType().GetProperty("Key").GetValue(x, null).ToString()
                            }));
                temp = temp.Concat(
                    ResourceFile3.ResourceManager
                        .GetResourceSet(CultureInfo.CurrentUICulture, true, true)
                        .Cast<object>()
                        .Select(
                            x => new
                                {
                                    ID = 3,
                                    Value = x.GetType().GetProperty("Value").GetValue(x, null).ToString(), …
Run Code Online (Sandbox Code Playgroud)

c# string intellisense dictionary visual-studio

0
推荐指数
1
解决办法
1045
查看次数

标签 统计

c# ×2

dictionary ×1

intellisense ×1

string ×1

using ×1

visual-studio ×1