小编Jay*_*lor的帖子

如何使用 console.log(); 对于多个变量

我正在使用 p5.js 和 Kinectron 让一台服务器计算机通过 LAN 显示来自另一台计算机的 RGB、深度和骨架数据,并且它是自己的 kinect。

使用 p5.js,我试图将两个不同的变量记录到控制台,但我只能记录其中一个变量。

代码:

   ...
    function drawJoint(joint) {
      fill(100);
      console.log( "kinect1" + joint);
      // Kinect location data needs to be normalized to canvas size
      ellipse( ( joint.depthX * 300 ) + 400 , joint.depthY * 300 , 15, 15);

      fill(200);

    ...

    function draw2Joint(joint2) {
      fill(100);
      console.log ("kinect2" + joint2);

      // Kinect location data needs to be normalized to canvas size
      ellipse(joint2.depthX * 300 , joint2.depthY * 300, 15, 15);

      fill(200);

      ...
Run Code Online (Sandbox Code Playgroud)

运行上述代码时,控制台仅实时显示来自 …

javascript console json console.log

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

在C#中将2个本地字符串[]添加到单个数组中

我们从2台客户端计算机接收两个字符串到第3台服务器计算机.该阵列目前是1维的.我们需要将result和answer数组的每个成员相加并输出第三个数组.但是我们将它们用作局部变量string[].

我们如何才能增加值answer和result一个阵列.例如:

answer[0]+result[0]= final[0]

..........

answer[76]+result[76]=final[76]
Run Code Online (Sandbox Code Playgroud)

更新了守则

    namespace ExampleLib.Server
{

    public class Server
    {
        string[] answer = new string[77];
        string[] result = new string[77];


    private void ClientReceiveData(object sender, ConnectedClient.NetDataEventArgs e)
    {
        if (string.IsNullOrEmpty(e.Message) == false)
        {
        if (e.ID == 0)
                {
                    answer = e.Message.Split(',');
                }

                if (e.ID==1)
                {
                    result = e.Message.Split(',');                    
                }
                var final = answer.Zip(result, (x, y) => x + y).ToArray();

                Trace.WriteLine(String.Join(Environment.NewLine, final));

            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

更新1(使用Zip方法): 在此输入图像描述

c# arrays string var

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

在C#中将字符串数组转换为float数组

我们在尝试运行此代码时遇到错误,理想情况下e.Message从更改 string为double或float array.请帮助我们了解错误的含义或如何调试代码.

我们也厌倦了一种float.Parse(e.Message, CultureInfo.InvariantCulture.NumberFormat);方法,这也导致了一个错误.

private void ClientReceiveData(object sender, ConnectedClient.NetDataEventArgs e)
{
    if (string.IsNullOrEmpty(e.Message) == false)
    {
        if (e.ID == 0)
        {
            //float.Parse(e.Message, CultureInfo.InvariantCulture.NumberFormat);
            Array.ConvertAll(e.Message.Split(','), Double.Parse);
            Trace.WriteLine(String.Join(Environment.NewLine, e.Message));
        }

        if (e.ID == 1)
        {
            //float.Parse(e.Message, CultureInfo.InvariantCulture.NumberFormat);
            Array.ConvertAll(e.Message.Split(','), Double.Parse);
            Trace.WriteLine(String.Join(Environment.NewLine, e.Message));
        }
    }
Run Code Online (Sandbox Code Playgroud)

INPUT(e.Message):

0.0160163, -0.3207418, -0.2747217, 0.9856872, -0.3428816, 0.02380935, 0.8472792, -0.3562718, 0.3080477, 0.6931204, -0.4135765, 0.2335226, 0.6617407, -0.2861188, 0.278595, 0.685502, -0.3337714, 0.06315409, 0.5661756, -0.5338272, 0.1274863, 0.6014508, -0.6020046, 0.149146, 0.6165056, -0.2287867, 0.108688, …
Run Code Online (Sandbox Code Playgroud)

c# arrays string floating-point double

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

标签 统计

arrays ×2

c# ×2

string ×2

console ×1

console.log ×1

double ×1

floating-point ×1

javascript ×1

json ×1

var ×1