小编Gre*_*ant的帖子

如何在 Visual Studio 2019 for c# 中定义默认名称字段建议

鉴于班级:

class BaseController
{
    BaseView _baseView;
    BaseModel _baseModel;
}
Run Code Online (Sandbox Code Playgroud)

在使用 Visual Studio 的建议命名时,它为我提供了名称base,而不是baseView. 我设法_通过选项、文本编辑器、c#、代码样式添加了前缀。但我看不到如何控制建议的字段名称建议。

我想知道,如果这可以被控制,因此建议_baseView_baseModel等。

c# ide intellisense coding-style visual-studio-2019

5
推荐指数
1
解决办法
587
查看次数

如果字符串存在于大型对象列表中,那么比较最快(性能)的方法是什么?

目前我有包含两个字符串的对象:

class myClass
{
    public string string1 { get; set; }
    public string string2 { get; set; }

    public bool MatcheString1(string newString)
    {
        if (this.string1 == newString)
        {
            return true;
        }
        return false;
    }
}
Run Code Online (Sandbox Code Playgroud)

然后,我有一个第二个类,使用List列出上述对象.

class URLs : IEnumerator, IEnumerable
{
    private List<myClass> myCustomList;
    private int position = -1;

    //  Constructor
    public URLs()
    {
        myCustomList = new List<myClass>();
    }
}
Run Code Online (Sandbox Code Playgroud)

在那个类中,我正在使用一种方法来检查列表中是否存在字符串

//  We can also check if the URL string is present in the collection
public bool ContainsString1(string newString) …
Run Code Online (Sandbox Code Playgroud)

c# string list

3
推荐指数
1
解决办法
126
查看次数

标签 统计

c# ×2

coding-style ×1

ide ×1

intellisense ×1

list ×1

string ×1

visual-studio-2019 ×1