小编Ham*_*han的帖子

如何从另一个类的类访问方法?

我想在JavaScript中使用面向对象编程技术但我无法从另一个类的一个类访问方法.怎么能这样呢?

class one{

  write(){
    console.log("Yes! I did!");
  }
}

class two{
   var object=new one();

   tryingMethod(){
   object.write();
   }
}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

未捕获的SyntaxError:意外的标识符 - >> for var object=new one();

javascript oop

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

如何从C#中的串口读取字节数组

我的 C# 串口编程有问题,
我的目标是将 ByteArray 发送到串口,而不是作为 ByteArray。但我无法从串口获取。我试过:

string gelen = port.ReadExisting();
   int asd = port.ReadByte();
   string qwe = port.ReadLine();
Run Code Online (Sandbox Code Playgroud)

谁能告诉我出了什么问题?谢谢

我的代码:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO.Ports;

    namespace serial_port_app
    {

        public partial class Form1 : Form
        {

            public Form1()
            {       
                InitializeComponent();

            }

            private void button1_Click(object sender, EventArgs e)
            {

                int text1, text2,text3,text4,text5, text6;

                Int32.TryParse(textBox1.Text, out text1);
                byte byteValue1 = Convert.ToByte(text1);

                Int32.TryParse(textBox2.Text, out text2);
                byte byteValue2 = Convert.ToByte(text2);

                Int32.TryParse(textBox3.Text, …
Run Code Online (Sandbox Code Playgroud)

c# serial-port bytearray

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

标签 统计

bytearray ×1

c# ×1

javascript ×1

oop ×1

serial-port ×1