RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

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

Berianidze Luka's questions

Martin Hope
Berianidze Luka
Asked: 2020-02-07 03:13:51 +0000 UTC

编译器使用大括号

  • 11

任何构造if都可以使用或不使用花括号来编写。例如:

bool j = true;
if(j==true)
    MessageBox.Show("That's true")

或者像这样:

bool j = true;
if(j==true)
{
   MessageBox.Show("That's true")
}

对话只是if一个动作的构造。因此有几个问题:

  1. 编译器会忽略这些括号吗?
  2. 如果没有,程序是否关注它们?
  3. 这些括号是否会影响程序的性能(即使是非常微不足道的)?
c#
  • 3 个回答
  • 10 Views
Martin Hope
Berianidze Luka
Asked: 2020-12-29 01:54:14 +0000 UTC

来自字符串的比较符号

  • 2

大家好,这样的东西很有意思,请问是否可以从string中获取比较符号(> < = >= <=)然后使用呢?

public class Main
{

   List<ListItem> ls = new List<ListItem>();
   private void FilterButtonClick(...)
   {
   if(Combobox1.SelectedText == "Id")
   {
       if(Combobox2.Selectedtext == ">=")
       {
       var its = ls.Where(z=>z.Id>=Convert.ToInt32(Textbox1.Text)).ToList();
       for(int i = 0;i<its.Count;i++)
       {
       datagridview.Rows.Add(Its[i].Name);
       }
       else if(Combobox2.Selectedtext == "<=")
       {
       var its = ls.Where(z=>z.Id<=Convert.ToInt32(Textbox1.Text)).ToList();
       for(int i = 0;i<its.Count;i++)
       {
       datagridview.Rows.Add(Its[i].Name);
       }
       }
   }
   else if(Combobox1.SelectedText == "Age")
   {
   if(Combobox2.Selectedtext == ">=")
       {
       var its = ls.Where(z=>z.Age>=Convert.ToInt32(Textbox1.Text)).ToList();
       for(int i = 0;i<its.Count;i++)
       {
       datagridview.Rows.Add(Its[i].Name);
       }
       else if(Combobox2.Selectedtext == "<=")
       {
       var its = ls.Where(z=>z.Age<=Convert.ToInt32(Textbox1.Text)).ToList();
       for(int i = 0;i<its.Count;i++)
       {
       datagridview.Rows.Add(Its[i].Name);
       }
       }
   }
   }

}
public class ListItem
{
string Name;
int Id;
int Age;
int birthday_date;
int Height;
int Weight;
}

我知道用 Switch 编写代码更好。但我在网站上写了,这样更方便。

c#
  • 2 个回答
  • 10 Views
Martin Hope
Berianidze Luka
Asked: 2020-12-02 13:30:36 +0000 UTC

按列表搜索<>

  • 0

假设有一堂课

public class Information
{
    public string Name;
    public string Surname;
    public int Age;
}

还有一类:

public class InfoByCities
{
    public List<InFormation> Moscow;
    public List<InFormation> Saint_Petersburg;
    public List<InFormation> Rostov;
}

填写这些List<>:

InfoByCities fill = new InfoByCities();
int Amount = 1500;

fill.Moscow = new List<Information>(Amount);
for (int i = 0; i < Amount; i++)
{
     Information inf = new Information();
     inf.Name = "Саша"+ i.ToString();
     inf.Surname = "Поляков" + i.ToString();
     inf.Age = i;
     fill.Moscow.Add(inf);
}

fill.Saint_Petersburg = new List<Information>(Amount); 
for (int i = 0; i < Amount; i++)
{
     Information inf = new Information();
     inf.Name = "Пётр" + i.ToString();
     inf.Surname = "Поляков" + i.ToString();
     inf.Age = i;
     fill.Saint_Petersburg.Add(inf);
}

fill.Rostov = new List<Information>(Amount);
for (int i = 0; i < Amount; i++)
{
     Information inf = new Information();
     inf.Name = "Саша" + i.ToString();
     inf.Surname = "Петухов" + i.ToString();
     inf.Age = i;
     fill.Rostov.Add(inf);
}

问题:如何在List<>不单独引用每个人的情况下实现对所有人的搜索。例如,要在所有三个列表中查找名称为“Sasha”的人。数量List<>可能更多。

c#
  • 1 个回答
  • 10 Views
Martin Hope
Berianidze Luka
Asked: 2020-11-22 18:30:24 +0000 UTC

替代工具提示实现

  • 3

大家好。需要制作替代版本的ToolTip. 选择WebBrowser第二种形式。这样的任务,鼠标悬停在Textboxin上,form1应该会出现Form2,上面也有一样的WebBrowser。但是问题是,鼠标移到Textboxin上Form1,Form2应该会跟着。但是Form1每次出现时它都会开始闪烁Form2。如何Form1让它出现时不闪烁Form2?

Form2 form2;
private void Texbox1_MouseEnter_1(object sender, EventArgs e) 
{ 
form2 = new form2();
form2.show(Texbox1); 
} 
private void Texbox1_MouseLeave_1(object sender, EventArgs e)
        {
            f2.Close();

        }
c#
  • 1 个回答
  • 10 Views
Martin Hope
Berianidze Luka
Asked: 2020-10-05 01:24:04 +0000 UTC

从文件中读取指定数量的字节

  • 3

各位晚上好。出现了以下问题:
假设我有一个文件,我想从中读取 128 个字节并将它们传输到string使用Encoding. 但同时,这128个字节中只占用了32个字节
,使用类后的字符串变量Encoding可能是这个样子:(firstdsda假设是32个字节),然后一切都是这个样子0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0(假设剩下的那96个,即,空字节)。

如果使用显示此变量,Messagebox.show(Это строка);则文本位于开头,然后是空字节,但它们是不可见的。

那么在输出\显示\之类的时候,如何截掉剩余的空字节呢?

c#
  • 2 个回答
  • 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