不能类型“string”隐式转换为'廉政' [英] Cannot implicitly convert type 'string' to 'int'

查看:154
本文介绍了不能类型“string”隐式转换为'廉政'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不断收到调试错误使用C#不能隐式转换类型'字符串'到'廉政'。

下面是我的code的一个片段:

 私人无效button2_Click(对象发件人,EventArgs五)//按钮开始移除
        {
            字节[] = packetData System.Text.ASCIIEncoding.ASCII.GetBytes(<分组数据在这里制造>);
            串IP =127.0.0.1;
            INT端口=80;            IPEndPoint EP =新IPEndPoint(IPAddress.Parse(IP),端口);            客户端的Socket =新的Socket(AddressFamily.InterNetwork,SocketType.Dgram,ProtocolType.Udp);
            client.SendTo(packetData,EP);
        }


解决方案

下面是错误:

  INT端口=80;

将其转换成

  INT端口= 80;

I keep getting the debug error "cannot implicitly convert type 'string' to 'int'" in C#.

Here is a snippet of my code:

private void button2_Click(object sender, EventArgs e) //button to start takedown
        {
            byte[] packetData = System.Text.ASCIIEncoding.ASCII.GetBytes("<Packet OF Data Here>");
            string IP = "127.0.0.1";
            int port = "80";

            IPEndPoint ep = new IPEndPoint(IPAddress.Parse(IP), port);

            Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            client.SendTo(packetData, ep);
        }

解决方案

Here is the error:

int port = "80";

convert it into

int port=80;

这篇关于不能类型“string”隐式转换为'廉政'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆