| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 705 人关注过本帖
标题:代码的结果运行不对
取消只看楼主 加入收藏
lhb62232397
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:1
帖 子:117
专家分:546
注 册:2011-11-6
结帖率:75%
收藏
已结贴  问题点数:20 回复次数:4 
代码的结果运行不对
namespace _8ChuXu
{
    class Program
    {
        static void Main()
        {
            int p = 5;
            int q = 4;
            Program pro = new Program();
            pro.select(p, q);
            Console.WriteLine(p );
            Console.ReadLine();
        }
        public void select(int a, int b)
        {

            a += b;
        }
        
    }
}
就是最后结果运行不对,请求帮忙解决
搜索更多相关主题的帖子: void class public 
2012-01-17 11:52
lhb62232397
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:1
帖 子:117
专家分:546
注 册:2011-11-6
收藏
得分:0 
我附带个有的难度的问题
class config()
{        
public Socket ClientSocket;
        private void button1_Click_1(object sender, EventArgs e)
        {                                
            IPEndPoint ServerInfo = new IPEndPoint(IPAddress.Parse("127.0.0.1"), Convert.ToInt32(6000));
            Socket ClientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            ClientSocket.Connect(ServerInfo);
            MessageBox.Show("连接成功!", "提示");           
        }
}
class program()
{   
        fmConfig pfmConfig = new fmConfig();
        public bool SendToClient(string data)
        {
            try
            {
                byte[] sendBuffer = new byte[10240];
                int dataLen = System.Text.Encoding.UTF8.GetBytes(data, 0, data.Length, sendBuffer, 4); //utf8编码
                sendBuffer[0] = 0x1F;
                sendBuffer[1] = 0xF1;
                CopyByte(sendBuffer, 2, dataLen, 2);
                dataLen += 4;
                pfmConfig.ClientSocket.BeginSend(sendBuffer, 0, dataLen, 0, new AsyncCallback(SendCallBack), pfmConfig.ClientSocket);//这条语句
                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }
}
上面的那条语句想调用config类中的ClientSocket,可以吗,有什么问题?
2012-01-17 13:29
lhb62232397
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:1
帖 子:117
专家分:546
注 册:2011-11-6
收藏
得分:0 
哪些类名不匹配,可以具体指出来,我一一解决
2012-01-18 09:00
lhb62232397
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:1
帖 子:117
专家分:546
注 册:2011-11-6
收藏
得分:0 
class fmconfig()
{        
public Socket ClientSocket;
        private void button1_Click_1(object sender, EventArgs e)
        {                                
            IPEndPoint ServerInfo = new IPEndPoint(IPAddress.Parse("127.0.0.1"), Convert.ToInt32(6000));
            Socket ClientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            ClientSocket.Connect(ServerInfo);
            MessageBox.Show("连接成功!", "提示");           
        }
}
class program()
{   
        fmConfig pfmConfig = new fmConfig();
        public bool SendToClient(string data)
        {
            try
            {
                byte[] sendBuffer = new byte[10240];
                int dataLen = System.Text.Encoding.UTF8.GetBytes(data, 0, data.Length, sendBuffer, 4); //utf8编码
                sendBuffer[0] = 0x1F;
                sendBuffer[1] = 0xF1;
                CopyByte(sendBuffer, 2, dataLen, 2);
                dataLen += 4;
                pfmConfig.ClientSocket.BeginSend(sendBuffer, 0, dataLen, 0, new AsyncCallback(SendCallBack), pfmConfig.ClientSocket);//这条语句
                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }
}
上面的那条语句想调用config类中的ClientSocket,可以吗,有什么问题?
抱歉,是我在论坛上写错了,现在改正确了。
可是怎么样才能正确调用,我调用的对吗
2012-01-18 14:55
lhb62232397
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:1
帖 子:117
专家分:546
注 册:2011-11-6
收藏
得分:0 
1、fmconfig类是公有的,可以在其他类中调用
2、button1_Click_1()是触发事件,触发完才调用ClientSocket的
那怎么样才能调用呢
2012-01-19 14:18
快速回复:代码的结果运行不对
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.040296 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved