类型System.Net.IPAddress不能分配给System.Net.IPAddress类型

时间:2017-05-09 23:46:30

标签: udp multicast .net-standard .net-standard-1.5

我正在用.net标准编写PCL,用于Android和IOS。

目前正在为设备发现编写UDP多播侦听器。

然而当我做的时候

<code>    @Override
    public int countNeighbours(int cellRow, int cellCol) {
        int neighbours = 0;
        for (int i = cellRow-1; i < cellRow + 2; i++) {
                for (int j = cellCol - 1; j < cellCol + 2; j++) {
                    if (GOLBoard[i][j] == 1) {
                        neighbours += 1;
                    }
                }
            }
        if (GOLBoard[cellRow][cellCol] == 1) {
            return(neighbours-1);
        } else {
            return(neighbours);
        }

    }



    @Override
    public int applyRules(int cellRow, int cellCol) {
        int alive = 0;
        if (GOLBoard[cellRow][cellCol] == 1) {
            if (countNeighbours(cellRow, cellCol) == 2 || countNeighbours(cellRow, cellCol) == 3) {
                alive = 1;
            } else if (countNeighbours(cellRow, cellCol) < 2 || countNeighbours(cellRow, cellCol) > 3) {
                alive = 0;
            } 
        }


        if (GOLBoard[cellRow][cellCol] == 0) {
            if (countNeighbours(cellRow, cellCol) == 3) {
                alive = 1;
            }
        }
        return (alive);
    }

    @Override
    public void takeStep() {
        for (int row = 1; row < 11; row++) {
            for (int col = 1; col < 11; col++) {
                GOLBoard[row][col] = applyRules(row, col);
            }
        }
    }



    @Override
    public String toString() {
        for (int row = 1; row < 11; row++) {
            for (int col = 1; col < 11; col++) {
                System.out.print("[" + GOLBoard[row][col] + "]");
            }
            System.out.println("");
        }
        return("");
    }
} <code>

它会有点错误但仍然编译,错误是

IPAddress multicastaddress = IPAddress.Parse("239.1.1.1");
client.JoinMulticastGroup(multicastaddress);

我的用法如下

Argument type 'System.Net.IPAddress [System.Net.Primitives, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]' is not assignable to parameter type 'System.Net.IPAddress [System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]'

我的package.json如下

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

我真的很想知道如何解决这个问题,我认为这可能会给我造成问题。任何帮助将不胜感激。

0 个答案:

没有答案