RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

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

Ярослав Овчар's questions

Martin Hope
Ярослав Овчар
Asked: 2024-10-07 02:56:07 +0000 UTC

在 JS 中通过 parseInt() 转换 null

  • 8

该问题采用非负整数和字符串列表并返回新的数字数组。

const filterlist = [1, 2, "a", "b", 0];

function filter_list(l) {
  let arrayResult = [];
  for (const iteml of l) {
    if (parseInt(iteml)) {
      arrayResult.push(iteml);
    }
  }
  return arrayResult;
}

const res = filter_list(filterlist);

for (let i = 0; i < res.length; i++) {
  console.log(res[i]);
}

// console.log(parseInt(0));

这样做时,结果发现只解析了 1 和 2,而 0 仍然悬而未决,但是为什么当我将转换带到控制台(注释行)时,它显示这是一个数字。我知道零是一个错误值,但是我该如何绕过它呢?

javascript
  • 3 个回答
  • 66 Views
Martin Hope
Ярослав Овчар
Asked: 2024-10-03 18:59:54 +0000 UTC

背景图像和响应式布局

  • 5

有一个布局(https://www.figma.com/design/v3CYjno3KdI1XdKkhe7okC/Web-Studio-(Version-2.1)-(Copy)?node-id=3-7653&node-type=canvas&t=GIj8ZFvJBqvxqICs-0)。横幅背景图像(英雄)有问题。对于移动版本,您需要宽度为视口的 100%,高度为 400px,但是使用这些样式,图像不能完全适合,但如果设置包含,则背景图像在居中且不拉伸。

.hero {
    padding-top: 118px;
    padding-bottom: 118px;

    min-height: 400px;
    background-image: linear-gradient(to right, rgba(47, 48, 58, 0.4), rgba(47, 48, 58, 0.4)), url("../images/hero/bg-img.jpg");
    background-image: url("../images/hero/bg-img.jpg");
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
}
<section class="hero">
        <h1 class="hero__title">Ефективні рішення для<br />вашого бізнесу</h1>
        <button type="button" class="button hero__button" data-modal-open>
          Замовити послугу
        </button>
      </section>
html
  • 1 个回答
  • 30 Views
Martin Hope
Ярослав Овчар
Asked: 2024-09-23 02:44:34 +0000 UTC

扩展悬停伪类的 svg 图标操作

  • 6

当您将鼠标悬停在链接上时,图标的背景和颜色必须发生变化。背景没有问题,但对于图标,事实证明它只会在我将鼠标悬停在其上时改变颜色,而不是链接中的任何位置。也就是说,首先出现背景,然后当您将光标拖动到图标本身时,其颜色会发生变化。如何修复它,以便当鼠标悬停在链接的任何区域时图标立即改变颜色?附上所有涉及的代码。

.list-social {
  display: flex;
}

.social-link {
  display: block;
  padding: 12px;
  width: 44px;
  height: 44px;
}

.social-icon {
  width: 20px;
  height: 20px;
  fill: var(--icon-color);
}

.social-link:hover {
  background-color: var(--accent-color);
  border-radius: 50%;
}

.social-icon:hover {
  fill: var(--white);
}
<a href="" class="social-link">
  <svg class="social-icon">
    <use href="./images/icons/symbol-defs.svg#icon-icon-instagram1"></use>
  </svg>
</a>

html
  • 1 个回答
  • 12 Views
Martin Hope
Ярослав Овчар
Asked: 2024-09-20 03:01:20 +0000 UTC

如何使用align-items HTML+CSS 居中

  • 5

使用此代码,除了“WebStudio”徽标之外,所有内容都使用 Flexbox 显示。请告诉我什么是错误。我附上 HTML 源代码:

/* var-css */

:root {
  --main-color: #757575;
  --sub-color: #212121;
  --accent-color: #2196f3;
  --white: #FFFFFF;
  --white-transp: rgba(255, 255, 255, 0.6);
}


/* general */

body {
  font-family: Roboto, sans-serif;
  color: var(--main-color);
}

.list {
  list-style: none;
}

.ref {
  text-decoration: none;
}

.container {
  margin-right: auto;
  margin-left: auto;
  padding-right: 15px;
  padding-left: 15px;
  width: 1200px;
  outline: 1px solid tomato;
}


/* header */

.container.header {
  display: flex;
  align-items: center;
}

.site-nav {
  display: flex;
}

.logo {
  margin-right: 93px;
  font-family: "Raleway", sans-serif;
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.03em;
  color: var(--accent-color);
}

.logo .black {
  color: var(--sub-color);
}

.nav-list {
  display: flex;
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 32px;
  padding-bottom: 32px;
  padding-left: 0;
}

.nav-item:not(:last-child) {
  margin-right: 50px;
}

.nav-ref {
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.02em;
  color: #212121;
}

.nav-ref:hover,
.nav-ref:focus {
  color: var(--accent-color);
}

.contacts-header {
  display: flex;
  margin-top: 0;
  margin-bottom: 0;
  margin-left: auto;
  padding-left: 0;
}

.contacts-item:not(:last-child) {
  margin-right: 50px;
}

.contacts-ref {
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.02em;
  color: #757575;
}

.contacts-ref:hover,
.contacts-ref:focus {
  color: var(--accent-color);
}


/* ----------------------------------------------- */
<header class="header">
  <div class="container header">
    <nav class="site-nav">
      <a href="./index.html" class="logo ref">Web<span class="black">Studio</span>
          </a>

      <ul class="nav-list list">
        <li class="nav-item"><a href="" class="nav-ref ref">Студія</a></li>
        <li class="nav-item">
          <a href="" class="nav-ref ref">Портфоліо</a>
        </li>
        <li class="nav-item">
          <a href="" class="nav-ref ref">Контакти</a>
        </li>
      </ul>
    </nav>

    <ul class="contacts-header list">
      <li class="contacts-item">
        <a href="mailto:[email protected]" class="contacts-ref ref">[email protected]</a
            >
          </li>
          <li class="contacts-item">
            <a href="tel:380961111111" class="contacts-ref ref"
              >+38 096 111 11 11</a
            >
          </li>
        </ul>
      </div>
    </header>

我已经尝试了我想到的一切,但仍然一无所获。

html
  • 1 个回答
  • 34 Views
Martin Hope
Ярослав Овчар
Asked: 2024-09-02 01:11:42 +0000 UTC

尝试将对象数据添加到列表时出现错误 CS1729

  • 5

大家好。添加到列表时发生错误 CS1729 - “Person”不包含接受 0 个参数的构造函数 请告诉我如何修复它。

List<Person> persons = new List<Person>();
persons.Add( new Person { Name = "Bob", Age = 10 });

class Person
{
    public string Name;
    public int Age;

    public Person(string name, int age)
    {
        Name = name;
        Age = age;
    }
}
c#
  • 1 个回答
  • 36 Views
Martin Hope
Ярослав Овчар
Asked: 2022-04-10 17:09:35 +0000 UTC

创建 C# 表单对象时出现 System.StackOverflowException

  • 1

有两种形式,一类。从主窗体我打开第二个:

private void button1_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();
            this.Hide();
            form2.ShowDialog();
            this.Close();
        }

在另一个类中,我还为第二种形式创建了一个对象

Form2 form2 = new Form2();

并且在这一行上它会抛出一个异常 System.StackOverflowException。我没有在第二个表单上创建对象。你怎么能解决这个问题?毕竟我需要通过这个类的方法来改变第二个窗体上的组件。这是整个代码:

 public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();
            this.Hide();
            form2.ShowDialog();
            this.Close();
        }
    }

public partial class Form2 : Form
    {
        Ans ans = new Ans();
        private int index = -1;

        public Form2()
        {
            InitializeComponent();
            ans.Test(radioButton1, radioButton2);

            Shown += Form1_Shown15;
        }

        private void radioButton_Click(object sender, EventArgs e)
        {
            RadioButton button = sender as RadioButton;

            if (button == radioButton1) { index = 0; }
            if (button == radioButton2) { index = 1; }
        }

        private async void Form1_Shown25(object sender, EventArgs e)
        {
            verticalProgressBar1.Value = 100;
            for (int i = 25 * 60; i > 0; i--)
            {
                verticalProgressBar1.Value = i * 100 / (25 * 60);
                await Task.Delay(1000);
            }
            Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                ans.Correct(index);

                radioButton1.Checked = false;
                radioButton2.Checked = false;

                index = -1;
            }
            catch { return; }

            ans.Index++;

            if (ans.Index > 47)
            {
                MessageBox.Show();
                return;
            }
            ans.Test(radioButton1, radioButton2);
        }
    }
public class Ans
{
 Form2 form2 = new Form2();

        private List<string> test = new List<string>()
        { };

        private bool[,] boolTest =
        { };

        public int correct = 0;

        public int TestIndex { get; set; }
        public int Index { get; set; }

        public string GetCorrect { get; set; }

        public void Test(Control control1, Control control2)
        {
            control1.Text = test[TestIndex];
            TestIndex++;
            control2.Text = test[TestIndex];
            TestIndex++;
        }

        public void Correct(int i)
        {
            SystemSounds.Exclamation.Play();
            #region 1-10
            //1
            if (Index == 0)
            {
                if (boolTest[0, i] == true)
                {
                    form2.pictureBox2.BackColor = Color.Green;
                    form2.label2.Text = "";
                    correct++;
                    return;
                }
                else
                {
                    form2.pictureBox2.BackColor = Color.Red;
                    form2.label2.BackColor = Color.Red;
                }
            }           
        }
    }
c#
  • 1 个回答
  • 10 Views
Martin Hope
Ярослав Овчар
Asked: 2022-04-10 01:58:59 +0000 UTC

计时器和进度条 C#

  • 1

我需要做一个 25 分钟的计时器,它会在时间到期时关闭表单。在这种情况下,应该有一个显示这 25 分钟的进度条。我尝试这样:

private void Form2_Load(object sender, EventArgs e)
        {
            progressBar1.Maximum = 25 * 60 * 1000;
            Timer MyTimer = new Timer();
            MyTimer.Interval = (25 * 60 * 1000); // 25 mins
            MyTimer.Tick += new EventHandler(MyTimer_Tick);
            MyTimer.Start();
        }

        private void MyTimer_Tick(object sender, EventArgs e)
        {
            count++;
            if (count <= 25 * 60 * 1000)
                progressBar1.Value = count;
            MessageBox.Show("The form will now be closed.", "Time Elapsed");
            this.Close();
        }

但是根据这段代码的结果,progressBar 什么都不显示。错误在哪里?并且progressBar可以垂直设置吗?

c#
  • 2 个回答
  • 10 Views
Martin Hope
Ярослав Овчар
Asked: 2022-03-14 14:51:24 +0000 UTC

C# WinForms 测试程序

  • 1

程序中有三个测试问题。这是主要的表单代码:

public partial class TestsForm : Form
    {
        private Ans ans = new Ans();

        private int index = -1;

        public TestsForm()
        {
            InitializeComponent();
     
            ans.Question(groupBox1);
            ans.Test(firstRadioButton, secondRadioButton, thirdRadioButton, fourthRadioButton);
            resultLabel.Text = ans.GetCorrect;
        }

        private void radioButton_Click(object sender, EventArgs e)
        {
            RadioButton button = sender as RadioButton;

            if (button == firstRadioButton) { index = 0; }
            if (button == secondRadioButton) { index = 1; }
            if (button == thirdRadioButton) { index = 2; }
            if (button == fourthRadioButton) { index = 3; }
        }

        private void answerButton_Click(object sender, EventArgs e)
        {
            try
            {
                ans.Correct(index, resultLabel);

                firstRadioButton.Checked = false;
                secondRadioButton.Checked = false;
                thirdRadioButton.Checked = false;
                fourthRadioButton.Checked = false;

                index = -1;
            }
            catch { return; }

            ans.Index++;

            if (ans.Index > 3) { MessageBox.Show("Congratulations!!!"); return; }

            ans.Question(groupBox1);
            ans.Test(firstRadioButton, secondRadioButton, thirdRadioButton, fourthRadioButton);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        } 
    }

这是 Ans 类的代码:

        private List<string> questions = new List<string>() { "Сколько будет два плюс два?", "Третья планета от Солнца?", "Какая из пречисленых планет не имеет твердой поверхности?" };
        private List<string> answers = new List<string>() { "4", "Земля", "Юпитер" };
        private List<string> test = new List<string>() { "5", "6", "4", "2", "Земля", "Марс", "Меркурий","Луна", "Плутон", "Юпитер", "Венера","Марс" };

        private bool[,] boolTest = { { false, false, true, false }, { true, false, false, false }, { false, true, false ,false} };

        private int correct = 0;

        public int TestIndex { get; set; }
        public int Index { get; set; }

        public string GetCorrect { get; set; }

        public void Question(Control control)
        {
            control.Text = questions[Index];
        }

        public void Test(Control control1, Control control2, Control control3, Control control4)
        {
            control1.Text = test[TestIndex];
            TestIndex++;
            control2.Text = test[TestIndex];
            TestIndex++;
            control3.Text = test[TestIndex];
            TestIndex++;
            control4.Text = test[TestIndex];
            TestIndex++;
        }

        public void Correct(int i, Control control)
        {
            if (Index == 0)
            {
                if (boolTest[0, i] == true)
                {
                    MessageBox.Show("Correct");
                    correct++;
                    GetCorrect = "Правильные ответы: " + correct.ToString() + " из 3";
                    control.Text = GetCorrect;

                    return;
                }
                else { MessageBox.Show("Not correct"); return; }
            }

            if (Index == 1)
            {
                if (boolTest[1, i] == true)
                {
                    MessageBox.Show("Correct");
                    correct++;
                    GetCorrect = "Правильные ответы: " + correct.ToString() + " из 3";
                    control.Text = GetCorrect;

                    return;
                }
                else { MessageBox.Show("Not correct"); return; }
            }

            if (Index == 2)
            {
                if (boolTest[2, i] == true)
                {
                    MessageBox.Show("Correct");
                    correct++;
                    GetCorrect = "Правильные ответы: " + correct.ToString() + " из 3";
                    control.Text = GetCorrect;

                    return;
                }
                else { MessageBox.Show("Not correct"); return; }
            }          
        }

问题是第四个 radioButton 不起作用。但是,如果在此之前您单击其他人并在最后单击第四个,那么它会记住以前的 RadioButton 并给出其结果。在此先感谢您的帮助!这是来自 Designer.cs 的自动生成的代码

 {
        /// <summary>
        /// Требуется переменная конструктора.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Освободить все используемые ресурсы.
        /// </summary>
        /// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Код, автоматически созданный конструктором форм Windows

        /// <summary>
        /// Обязательный метод для поддержки конструктора - не изменяйте
        /// содержимое данного метода при помощи редактора кода.
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TestsForm));
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.answerButton = new System.Windows.Forms.Button();
            this.resultLabel = new System.Windows.Forms.Label();
            this.thirdRadioButton = new System.Windows.Forms.RadioButton();
            this.secondRadioButton = new System.Windows.Forms.RadioButton();
            this.firstRadioButton = new System.Windows.Forms.RadioButton();
            this.pictureBox1 = new System.Windows.Forms.PictureBox();
            this.panel1 = new System.Windows.Forms.Panel();
            this.button1 = new System.Windows.Forms.Button();
            this.StartTestButton = new System.Windows.Forms.Button();
            this.panel2 = new System.Windows.Forms.Panel();
            this.label1 = new System.Windows.Forms.Label();
            this.fourthRadioButton = new System.Windows.Forms.RadioButton();
            this.groupBox1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
            this.panel1.SuspendLayout();
            this.panel2.SuspendLayout();
            this.SuspendLayout();
            // 
            // groupBox1
            // 
            this.groupBox1.BackColor = System.Drawing.Color.Transparent;
            this.groupBox1.Controls.Add(this.fourthRadioButton);
            this.groupBox1.Controls.Add(this.answerButton);
            this.groupBox1.Controls.Add(this.resultLabel);
            this.groupBox1.Controls.Add(this.thirdRadioButton);
            this.groupBox1.Controls.Add(this.secondRadioButton);
            this.groupBox1.Controls.Add(this.firstRadioButton);
            this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.groupBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
            this.groupBox1.Location = new System.Drawing.Point(0, 46);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(538, 540);
            this.groupBox1.TabIndex = 0;
            this.groupBox1.TabStop = false;
            // 
            // answerButton
            // 
            this.answerButton.Location = new System.Drawing.Point(6, 144);
            this.answerButton.Name = "answerButton";
            this.answerButton.Size = new System.Drawing.Size(218, 23);
            this.answerButton.TabIndex = 4;
            this.answerButton.Text = "Ответить";
            this.answerButton.UseVisualStyleBackColor = true;
            this.answerButton.Click += new System.EventHandler(this.answerButton_Click);
            // 
            // resultLabel
            // 
            this.resultLabel.AutoSize = true;
            this.resultLabel.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
            this.resultLabel.Location = new System.Drawing.Point(6, 112);
            this.resultLabel.Name = "resultLabel";
            this.resultLabel.Size = new System.Drawing.Size(0, 15);
            this.resultLabel.TabIndex = 3;
            // 
            // thirdRadioButton
            // 
            this.thirdRadioButton.AutoSize = true;
            this.thirdRadioButton.Location = new System.Drawing.Point(6, 74);
            this.thirdRadioButton.Name = "thirdRadioButton";
            this.thirdRadioButton.Size = new System.Drawing.Size(14, 13);
            this.thirdRadioButton.TabIndex = 2;
            this.thirdRadioButton.UseVisualStyleBackColor = true;
            this.thirdRadioButton.Click += new System.EventHandler(this.radioButton_Click);
            // 
            // secondRadioButton
            // 
            this.secondRadioButton.AutoSize = true;
            this.secondRadioButton.Location = new System.Drawing.Point(6, 51);
            this.secondRadioButton.Name = "secondRadioButton";
            this.secondRadioButton.Size = new System.Drawing.Size(14, 13);
            this.secondRadioButton.TabIndex = 1;
            this.secondRadioButton.UseVisualStyleBackColor = true;
            this.secondRadioButton.Click += new System.EventHandler(this.radioButton_Click);
            // 
            // firstRadioButton
            // 
            this.firstRadioButton.AutoSize = true;
            this.firstRadioButton.Location = new System.Drawing.Point(6, 28);
            this.firstRadioButton.Name = "firstRadioButton";
            this.firstRadioButton.Size = new System.Drawing.Size(14, 13);
            this.firstRadioButton.TabIndex = 0;
            this.firstRadioButton.UseVisualStyleBackColor = true;
            this.firstRadioButton.Click += new System.EventHandler(this.radioButton_Click);
            // 
            // pictureBox1
            // 
            this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
            this.pictureBox1.Location = new System.Drawing.Point(-1, 0);
            this.pictureBox1.Name = "pictureBox1";
            this.pictureBox1.Size = new System.Drawing.Size(538, 54);
            this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
            this.pictureBox1.TabIndex = 6;
            this.pictureBox1.TabStop = false;
            // 
            // panel1
            // 
            this.panel1.BackColor = System.Drawing.SystemColors.InactiveBorder;
            this.panel1.Controls.Add(this.button1);
            this.panel1.Controls.Add(this.StartTestButton);
            this.panel1.Location = new System.Drawing.Point(709, 28);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(538, 575);
            this.panel1.TabIndex = 7;
            // 
            // button1
            // 
            this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
            this.button1.Location = new System.Drawing.Point(162, 328);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(217, 46);
            this.button1.TabIndex = 14;
            this.button1.Text = "Вийти";
            this.button1.UseVisualStyleBackColor = true;
            // 
            // StartTestButton
            // 
            this.StartTestButton.BackColor = System.Drawing.SystemColors.Control;
            this.StartTestButton.FlatAppearance.BorderSize = 0;
            this.StartTestButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.StartTestButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
            this.StartTestButton.ForeColor = System.Drawing.Color.Black;
            this.StartTestButton.Image = ((System.Drawing.Image)(resources.GetObject("StartTestButton.Image")));
            this.StartTestButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.StartTestButton.Location = new System.Drawing.Point(128, 106);
            this.StartTestButton.Margin = new System.Windows.Forms.Padding(2);
            this.StartTestButton.Name = "StartTestButton";
            this.StartTestButton.Size = new System.Drawing.Size(290, 144);
            this.StartTestButton.TabIndex = 13;
            this.StartTestButton.Text = "Пройти тест";
            this.StartTestButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
            this.StartTestButton.UseVisualStyleBackColor = false;
            this.StartTestButton.Click += new System.EventHandler(this.StartTestButton_Click_1);
            // 
            // panel2
            // 
            this.panel2.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panel2.BackgroundImage")));
            this.panel2.Controls.Add(this.label1);
            this.panel2.Controls.Add(this.groupBox1);
            this.panel2.Location = new System.Drawing.Point(-1, 51);
            this.panel2.Name = "panel2";
            this.panel2.Size = new System.Drawing.Size(538, 586);
            this.panel2.TabIndex = 9;
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.BackColor = System.Drawing.Color.Transparent;
            this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
            this.label1.Location = new System.Drawing.Point(3, 6);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(313, 24);
            this.label1.TabIndex = 1;
            this.label1.Text = "Тема: Стародавня історія України";
            // 
            // fourthRadioButton
            // 
            this.fourthRadioButton.AutoSize = true;
            this.fourthRadioButton.Location = new System.Drawing.Point(6, 96);
            this.fourthRadioButton.Name = "fourthRadioButton";
            this.fourthRadioButton.Size = new System.Drawing.Size(14, 13);
            this.fourthRadioButton.TabIndex = 5;
            this.fourthRadioButton.UseVisualStyleBackColor = true;
            // 
            // TestsForm
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(1529, 636);
            this.Controls.Add(this.panel2);
            this.Controls.Add(this.panel1);
            this.Controls.Add(this.pictureBox1);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.MaximizeBox = false;
            this.Name = "TestsForm";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Тести з історії України";
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
            this.panel1.ResumeLayout(false);
            this.panel2.ResumeLayout(false);
            this.panel2.PerformLayout();
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.GroupBox groupBox1;
        private System.Windows.Forms.Button answerButton;
        private System.Windows.Forms.Label resultLabel;
        private System.Windows.Forms.RadioButton fourthRadioButton;
        private System.Windows.Forms.RadioButton thirdRadioButton;
        private System.Windows.Forms.RadioButton secondRadioButton;
        private System.Windows.Forms.RadioButton firstRadioButton;
        private System.Windows.Forms.PictureBox pictureBox1;
        private System.Windows.Forms.Panel panel1;
        private System.Windows.Forms.Button StartTestButton;
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.Panel panel2;
        private System.Windows.Forms.Label label1;
    }
c#
  • 1 个回答
  • 10 Views
Martin Hope
Ярослав Овчар
Asked: 2021-11-03 04:32:34 +0000 UTC

C# 数组比较

  • 1

有一个文本文档,其中将以下内容写在一个列中(示例):11123 大纲,11124 苦艾酒,11125 苦艾酒,11126 荒谬,11131 布尔利亚,11132 阿布哈兹。而且有很多这样的行,几乎 6000。它们的索引从 1000 到 6666。我以这种方式得到所有这些行

string[] lines = File.ReadAllLines(@"F:\VS Projects\Со звёздочкой\diceware.txt");

然后我形成一个 int 类型的数组,由 5 个从 1 到 6 的随机元素组成。底线是,通过这些随机数,我必须在这个索引处找到一个单词并输出 yogo。这就是我正在尝试的方式

int[] arr1 = new int[5]; //Массив с рандомными значениями, представим, что значения уже там есть.

for ( int i = 0; i < lines.Length; i++)
{
char[] textByCharacter = lines[i].ToCharArray(); //Строку перевожу в массив символов.
int yes = object1.Sravnenie(arr1, textByCharacter); //Метод, в котором я пытаюсь сравнить
if ( yes == 5)
{
textBox.Text = lines[i];
break;
}
}

比较方法本身:

public int Sravnenie(int[] numbers, char[] ch)
        {
            int yes = 0;

            int[] transfer = new int[5];
            for (int i = 0; i < 5; i++) //Беру 5, так как первые 5 символом это индекс слова
            {
                transfer[i] = Convert.ToInt32(ch[i]);
            }

            for (int i = 0; i < 5; i++)
            {
                if (numbers[i] == transfer[i])
                {
                    yes++;
                }
            }
            return yes;
        }

但最终它对我不起作用。如何决定?提前致谢!

c#
  • 1 个回答
  • 10 Views
Martin Hope
Ярослав Овчар
Asked: 2021-11-02 23:39:51 +0000 UTC

如何将文件中的行写入文本框行集合?

  • 1

我有一个文本文档,其中的单词写在一个列中。我得到并输出这些词是这样的:

System.IO.StreamReader file = new System.IO.StreamReader(@"F:\VS Projects\Со звёздочкой\diceware.txt");
while ((line = file.ReadLine()) != null)
{
    textBox1.AppendText(line + "\t\t");
}           

但后来事实证明,我没有添加到集合中,而是简单地移动光标。将来,我需要遍历这些行以获得特定的单词。如何写入集合?

尝试这样做:

textBox1.Lines[0] = line;

但随后它会引发 System.IndexOutOfRangeException。

c#
  • 1 个回答
  • 10 Views
Martin Hope
Ярослав Овчар
Asked: 2021-10-22 18:41:18 +0000 UTC

如何解决pictureBox中的NullReferenceException?

  • 0

此代码引发异常

Bitmap image1;
image1 = (Bitmap)pictureBox1.Image;
for (x = 0; x < image1.Width; x++)
                {
                    for (y = 0; y < image1.Height; y++)
                    {
                        image1.SetPixel(x, y, newColor);
                    }
                }

如果我不在此行的图片框中加载图像,则触发

image1.SetPixel(x, y, newColor);

如何决定?

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