小编Dav*_*haw的帖子

跳跃断点 - 他们为什么跳?

调试器目前设置为此行... 在此输入图像描述

但是之后

在此输入图像描述

为什么?

f# visual-studio-2010

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

Linq的表现包含

我需要使用过滤器列表过滤linq查询,我计划使用contains方法来执行此操作.所以它看起来像这样.

List<string> filter = new List<string>();
filter.Add("foo");
filter.Add("bar");
//Additional filters go here, max of about 10 filters
var test = dbcontext.books.Where(x => filter.Contains(x.name)).ToList();
Run Code Online (Sandbox Code Playgroud)

此查询后面的表有很多记录(500,000),PK标识字段和我要查询的字段上的索引.

我的问题是在走这条路线之前您是否希望此查询的性能可以接受,或者我应该在这么大的数据集上使用不同的方法?

c# linq linq-to-sql

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

为什么LINQ中的区别对于这种情况不起作用?

我的对象有这个比较器 Tenant

public class TenantComparer : IEqualityComparer<Tenant>
{
    // Products are equal if their names and product numbers are equal.
    public bool Equals(Tenant x, Tenant y)
    {

        //Check whether the compared objects reference the same data.
        if (Object.ReferenceEquals(x, y)) return true;

        //Check whether any of the compared objects is null.
        if (Object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null))
            return false;

        //Check whether the products' properties are equal.
        return x.Name == y.Name;
    }

    // If Equals() returns true for a pair of objects …
Run Code Online (Sandbox Code Playgroud)

c# linq

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

错误C2143:缺少';' 之前' - >'

我在这里和互联网上搜索过,似乎没有人遇到类似的问题,我无法弄清楚为什么我不能让这个工作.

阻止我编译的那一行是:

LitCiterCommon::LitCiterTrace->Init();
Run Code Online (Sandbox Code Playgroud)

如果我LitCiterTrace.Init()从另一个文件(c#)调用它编译得很好,但由于某种原因我无法从托管cpp调用它.

任何想法或建议?

c# c++-cli managed

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

如何只在字符串的第一句中找到一个字母的出现次数?

我想在第一句中找到字母"a"的数量.下面的代码在所有句子中都找到了"a",但我只想要第一句话.

static void Main(string[] args)
{
    string text;  int k = 0;
    text = "bla bla bla. something second. maybe last sentence.";

    foreach (char a in text)
    {
        char b = 'a';
        if (b == a)
        {
            k += 1;
        }
    }

    Console.WriteLine("number of a in first sentence is " + k);
    Console.ReadKey();
}
Run Code Online (Sandbox Code Playgroud)

c# string char

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

使用三元运算符从三个变量返回最低值

我有三个变量,所有的整数.

indexA
indexB
indexC
Run Code Online (Sandbox Code Playgroud)

现在,使用三元运算符,如何在三者中返回最低值?

c# ternary-operator

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

(&(objectCategory = user)(|(CN =)(sAMAccountName =)))搜索过滤器无效

(&(objectCategory = user)(|(CN =)(sAMAccountName =)))搜索过滤器无效.

有人能告诉我这个错误出现在什么情况下?

我试图通过Visual Studio发布我的Web应用程序.我在本地主机上运行正常,但在发布后出现此错误.

 public static string[] ldapUserQuery(string userName, string[] desiredProps)
    {
        //  Establishes path for query. In this case sap.corp
        string queryPath = "LDAP://DC=SAP,DC=CORP";

        //  Used to establish desiredProps from within the function, but now it can be passed in.
        //  This was kept in here as an example of what the desiredProps should look like when
        //  passing it in.
        //
        //  Desired pros are the LDAP attributes to be returned.
        /*
            string[] desiredProps …
Run Code Online (Sandbox Code Playgroud)

c# asp.net active-directory

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

无法一次捕获所有异常C#

我正在对一个xml文件进行去序列化,我正在尝试使用下面的代码捕获所有异常艺术,但它只捕获一个异常.我在这做什么错?

码:

StringBuilder exBuilder;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
    var fileName = openFileDialog1.FileName;
    mruOpenRseConfig.AddRecentFile(fileName);
    try
    {
        ConfigDeserialized = MyConfig.DeserializeFromXmlFile(fileName);

    }

    catch (Exception ex)
    {
        if (ex is DataConsistencyException ||
            ex is XmlException)
        {
            exBuilder.Clear();
            exBuilder.Append(ex.Message + Environment.NewLine);

            RichTextBox richTextBox = new RichTextBox();

            richTextBox.Text = exBuilder;
            richTextBox.Dock = DockStyle.Fill;


            Form richMessageBox = new Form
            {
                StartPosition = FormStartPosition.CenterScreen,
                ControlBox = true,
                Text = "Error in File",
                MaximizeBox = false,
                MinimizeBox = false
            };

            richMessageBox.Controls.Add(richTextBox);

            richMessageBox.ShowDialog();
            return;
        }
        throw;
    }
}
Run Code Online (Sandbox Code Playgroud)

c# exception xml-serialization richtextbox winforms

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

为什么我不能使用StreamWriter向文件追加一行?

为什么我的程序会覆盖文件中的同一行?

我希望它每次使用时记录一行StreamWriter.

String path = @"c:\Observer\Employer\Employer.txt";
TextWriter write1 = new StreamWriter(path);

if (!File.Exists(path))
{
    File.Create(path);
    TextWriter write2 = new StreamWriter(path);
    write2.WriteLine(Info);
    write2.Close();
}
else if (File.Exists(path))
{
    write1.WriteLine(Info);
    write1.Close();
}

write1.Close();
Run Code Online (Sandbox Code Playgroud)

c#

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

单击菜单时如何开始Snackbar消息?

单击菜单时如何开始Snackbar消息?

public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case (R.id.reset):
            number1.setText(null);
            number2.setText(null);
            //Snackbar.make(findViewById(android.R.id.content) , "Text", Snackbar.LENGTH_SHORT).setAction("Action", null).show();
            break;
        case (R.id.quit):
             finish();
             break;
    }

    return super.onOptionsItemSelected(item);
}
Run Code Online (Sandbox Code Playgroud)

它没有反应.

snackbar

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

c#如何在select语句中指定not?

我在数据集上使用select方法来检索符合我条件的结果:

foreach (DataRow dr in dsPone2.Tables["tt-pone"].Select(strWhereCondition))
{
    dsPone.Tables["tt-pone"].ImportRow(dr);
}
Run Code Online (Sandbox Code Playgroud)

如何更改strWhereCondition

strWhereCondition += " AND poneid = 0 and aoneid = 0 and tranid = 0";
Run Code Online (Sandbox Code Playgroud)

到tranid不是0的地方?

我使用<>!=

c# datatable

-1
推荐指数
1
解决办法
2万
查看次数

为什么string.Split("")返回元素,即使分隔符不存在?

在下面的:

string input = "123";
char [] separators = " ".ToCharArray();
string [] elements = input.Split(separators);
Run Code Online (Sandbox Code Playgroud)

elements阵列是.长度= 1.

这是为什么?String 123不包含任何空格.

.net c#

-1
推荐指数
1
解决办法
54
查看次数

相交两个列表c#

你好,我有这两个列表

List<string> list1 = {"404a49ad-d80f-4ef7-99ab-0996de3b70d4_29190_806.jpg|Name1", "404a49ad-d80f-4ef7-99ab-0996de3b70d4_29197_806.jpg|Name2", "404a49ad-d80f-4ef7-99ab-0996de3b70d4_29210_868.jpg|Name3"}
List<string> list2 = {"404a49ad-d80f-4ef7-99ab-0996de3b70d4_29190_806.jpg","404a49ad-d80f-4ef7-99ab-0996de3b70d4_29197_806.jpg"}
Run Code Online (Sandbox Code Playgroud)

我希望将list1的值与'|'相交 具有list2值的字符,但我想返回list1的完整字符串,而不仅仅是以'|'分隔的第一部分 字符.

这是我想要的结果:

var finalList = {"404a49ad-d80f-4ef7-99ab-0996de3b70d4_29190_806.jpg|Name1", "404a49ad-d80f-4ef7-99ab-0996de3b70d4_29197_806.jpg|Name2"}
Run Code Online (Sandbox Code Playgroud)

我不知道它是否可能与instersect功能或我可以使用的另一种方法.我已经尝试在谓词中使用Contains函数,但是需要很长时间才能找到匹配项.

我正在使用大约2000个元素的大型列表.

谢谢!

c# linq list

-2
推荐指数
1
解决办法
445
查看次数