RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-200461

zergon321's questions

Martin Hope
zergon321
Asked: 2020-03-27 02:24:19 +0000 UTC

在 LINQ 中按 2 个字段分组

  • 0

有 2 个数据集 - 宠物:

Pet[] pets =
        {
            new Pet() { Name = "Vasya", Type = "Cat", Owner = "John" },
            new Pet() { Name = "Borya", Type = "Dog", Owner = "Dean" },
            new Pet() { Name = "Kim", Type = "Hedgehog", Owner = "Mary" },
            new Pet() { Name = "Joka", Type = "Dog", Owner = "John" },
            new Pet() { Name = "Mursick", Type = "Cat", Owner = "Dean" },
            new Pet() { Name = "Mick", Type = "Cat", Owner = "Mary" },
            new Pet() { Name = "John", Type = "Hedgehog", Owner = "John" },
            new Pet() { Name = "Jynx", Type = "Dog", Owner = "Dean" }
        };

和他们的主人:

Owner[] owners =
        {
            new Owner() { Name = "John", Country = "USA" },
            new Owner() { Name = "Mary", Country = "Switzerland" },
            new Owner() { Name = "Dean", Country = "Great Britain" }
        };

从这两组中,我想确定每个国家有多少每种类型的宠物。那些。我需要一个与此SQL查询等效的LINQ查询:

SELECT O.Country, P.Type, Count(P.Type) AS Amount
FROM owners AS O INNER JOIN pets AS P
ON O.Name = P.Owner
GROUP BY O.Country, P.Type;

有可能用LINQ得到这个吗?

c#
  • 2 个回答
  • 10 Views
Martin Hope
zergon321
Asked: 2020-01-24 22:41:44 +0000 UTC

异步方法的工作原理

  • 2

有以下 C# 代码:

using System;
using System.Threading.Tasks;
using AlgorithmTools;

namespace AsyncMethods
{
    class Program
    {
        public static async void MethAsync(int num) => Console.WriteLine($"Factorial of {num} is {await FactorialAsync(num)}");

    private static Task<int> FactorialAsync(int num)
    {
        return Task.Factory.StartNew(() =>
                {
                    int result = 1;

                    foreach (int i in new Range(2, num + 1))
                        result *= i;

                    return result;
                });
    }

    static void Main(string[] args)
    {
        MethAsync(5);
    }
}
}

因为 当在返回值块上MethAsync调用并将控制权转移给方法时,程序应该终止而不打印阶乘值,但是,它被打印了。但是,如果不是返回值is ,那么一切都会按原样完成,它将在计算阶乘之前结束。为什么会这样?awaitFactorialAsyncMainvoidMethAsyncTaskMain

c#
  • 1 个回答
  • 10 Views
Martin Hope
zergon321
Asked: 2020-09-30 23:15:41 +0000 UTC

Tor如何找到节点来构建链?

  • 0

Tor客户端通过一系列服务器发送加密流量,而流量本身则使用所有服务器的公钥加密。问题:客户端如何找到链中第一台服务器的IP地址?他甚至从哪里获得有关哪些服务器可用于构建链的信息?他从哪里获得他们的公钥:参考服务器本身,或者从同一个地方,他从哪里获得可用服务器的IP地址?而且,也许,最重要的事情是:如何在确保所有这些程序的同时保持匿名性(在沿着链发送流量本身之前)?

сеть
  • 1 个回答
  • 10 Views
Martin Hope
zergon321
Asked: 2020-09-29 02:37:53 +0000 UTC

如何通过 Windows 窗体输入矩阵/数组元素?

  • 1

我用DataGridView. 我查看了许多用例,但是当我尝试在自己的代码中做某事时,在调试时,组件本身DataGridView显示为一个灰色矩形,没有任何列和行。该组件仅将程序的主窗体视为数据源Form1。需要在属性列表中编辑哪些内容并添加到代码中才能输入元素并对其进行计数?

在输入数组及其进一步处理(arrayGrid-object DataGridView)的示例中:

private void button1_Click(object sender, EventArgs e)
    {
        arrayGrid.RowCount = 1;
        arrayGrid.ColumnCount = SIZE;

        arrayGrid.Rows.Add();
        for (int i = 0; i < SIZE; i++)
            arrayGrid.Columns.Add("column" + i.ToString(), i.ToString());

        for (int i = 0; i < SIZE; i++)
            arr[i] = int.Parse((string)arrayGrid.Rows[0].Cells[i].Value);

        int min = arr[0];

        for (int i = 1; i < SIZE; i++)
            if (arr[i] < min)
                min = arr[i];

        label3.Text = min.ToString();
    }
c#
  • 1 个回答
  • 10 Views
Martin Hope
zergon321
Asked: 2020-08-24 06:07:49 +0000 UTC

Visual Studio 2017 看不到包含

  • 4

Visual Studio 2017看不到头文件Windows.h, WinSock2.h, WS2tcpip.h.
需要安装哪些版本的Visual C++以及需要在 Visual Studio 本身中完成哪些操作才能使用上述所有功能?

c++
  • 1 个回答
  • 10 Views
Martin Hope
zergon321
Asked: 2020-03-16 00:57:59 +0000 UTC

接口继承问题

  • 3

为什么在编译时:

using System;

public class Test
{
  public static void Main()
  {
    Lol l = new Lol();
    Console.WriteLine(((IParent)l).Family);
    Console.WriteLine(((IChild)l).Family);
    Console.WriteLine(l.Name);
  }
}

public interface IParent
{
  string Family { get; }
}

public interface IChild : IParent
{
  string Name { get; }
}

public class Lol : IChild
{
  string IParent.Family { get { return "suck"; } }
  string IChild.Family { get { return "duck"; } }
  public string Name { get { return "ross"; } }
}

IdeOne 给出了这个:

prog.cs(27,26):错误 CS0550:Lol.IChild.Family.get是在接口成员编译失败中找不到的访问器IChild.Family :1 个错误,0 个警告

c#
  • 1 个回答
  • 10 Views
Martin Hope
zergon321
Asked: 2020-02-11 19:39:32 +0000 UTC

JS-文件上传

  • -1

有没有可能这样做:web文档一传到用户电脑上,就启动一个js脚本,偷偷下载一个二进制文件到用户电脑上启动执行?如何实施?我自己没学过JS,我主要是想看看自己需要的东西能不能实现。

javascript
  • 3 个回答
  • 10 Views
Martin Hope
zergon321
Asked: 2020-10-19 23:35:01 +0000 UTC

在 Tkinter 中放置控件

  • 0

我正在制作一个简单的 GUI 程序:

在此处输入图像描述

彼此相邻的 Entry 和 Button 对象必须低三个单元格。怎么做?这是代码本身:

from tkinter import *

class Shell(Frame):

def __init__(self, window):
    super().__init__(window)
    self.grid()
    self.__clicked = 0
    self.__init_widgets()

def __init_widgets(self):
    self.__lbl = Label(self, text = "Button clicked: " + str(self.__clicked))
    self.__lbl.grid(row = 0, column = 0, columnspan = 2, sticky = W)

    self.__btn = Button(self, text = "Click on me", command = self.__clicker)
    self.__btn.grid(row = 0, column = 2, columnspan = 2, sticky = W)

    self.__ent = Entry(self)
    self.__ent.grid(row = 3, column = 0, columnspan = 2, sticky = W)

    self.__ent_button = Button(self, text = "Enter", command = self.__input_bold)
    self.__ent_button.grid(row = 3, column = 2, sticky = W)

    self.__fuck_label = Label(self, text = "Hey, bitch")
    self.__fuck_label.grid(row = 5, columnspan = 3)

def __clicker(self):
    self.__clicked += 1
    self.__lbl["text"] = "Button clicked: " + str(self.__clicked)

def __input_bold(self):
    if self.__ent.get() == "Fuck you":
        self.__fuck_label["text"] = "O_0"
    else:
        self.__fuck_label["text"] = "What a fuck did you say?!"


if __name__ == "__main__":

main_window = Tk()

main_window.title("Clicker")
main_window.geometry("200x200")

shell = Shell(main_window)

main_window.mainloop()
python
  • 1 个回答
  • 10 Views
Martin Hope
zergon321
Asked: 2020-09-29 01:48:19 +0000 UTC

在 Python 中分配整数 (int)

  • 15

假设我们有以下代码:

a = 32
b = a

print(a is b)

如何使 b 成为对内存中新值的引用,而不是 a 引用的值,即 如何使操作print(a is b)打印出来False?

python
  • 3 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5