| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 529 人关注过本帖
标题:[求助]函数调用出错!
只看楼主 加入收藏
xiaxun
Rank: 1
等 级:新手上路
帖 子:207
专家分:7
注 册:2009-8-30
结帖率:79.31%
收藏
已结贴  问题点数:16 回复次数:6 
[求助]函数调用出错!
错误 1 非静态的字段、方法或属性“sanjiaoxing.Program.qwx(string)”要求对象引用


我的代码
namespace sssssss
{
    class Program
    {
        int s;
     
          string qwx(string w)
        {
            if (int.TryParse(w, out s))
            {
                return "right";
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.Write("输入数据“{0}”有误,:", w);
                Console.ForegroundColor = ConsoleColor.White;
                return "wrong";
            }
        }

        static void Main(string[] args)
        {
           
            while (true)
            {
                int a, b, c;
                string a1, b1, c1,a2,b2,b3;
                Console.Write("\n");
                Console.ForegroundColor = ConsoleColor.White;
                while (true)
                {
                    Console.WriteLine("请输入第1数:");
                    a1 = Console.ReadLine();
                    a2 =qwx(a1);
                    if (a2 == "right")
                    {
                        break;
                    }
                    else
                    {
                        continue;
                    }           
                }
            }
        }
    }
}







请大家帮忙!

来源: http://www.
搜索更多相关主题的帖子: 函数 
2010-11-14 16:22
梦灵儿
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:260
专家分:9
注 册:2007-8-7
收藏
得分:0 
现在报哪步出问题了?

2010-11-14 16:40
xiaxun
Rank: 1
等 级:新手上路
帖 子:207
专家分:7
注 册:2009-8-30
收藏
得分:0 
错误 1 非静态的字段、方法或属性“sanjiaoxing.Program.qwx(string)”要求对象引用
2010-11-14 17:11
c1_wangyf
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:7
帖 子:665
专家分:2832
注 册:2010-5-24
收藏
得分:0 
好像你的程序里面没有sanjiaoxing命名空间啊,你的把它加上!!--using sanjiaoxing;
2010-11-14 22:12
xiaxun
Rank: 1
等 级:新手上路
帖 子:207
专家分:7
注 册:2009-8-30
收藏
得分:0 
不是这样的!关命名空间什么事情。那个都可以换的!
2010-11-14 23:36
wangnannan
Rank: 18Rank: 18Rank: 18Rank: 18Rank: 18
等 级:贵宾
威 望:87
帖 子:2546
专家分:9359
注 册:2007-11-3
收藏
得分:16 
已经解决 楼主看看 基础不扎实啊
程序代码:
using System;
using System.Collections.Generic;
using System.Text;

namespace sssssss
{
    class Program
    {
        //修改为静态变量
        static int s;
        // 修改为静态方法
        static  string qwx(string w)
        {
            if (int.TryParse(w, out s))
            {
                return "right";
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.Write("输入数据“{0}”有误,:", w);
                Console.ForegroundColor = ConsoleColor.White;
                return "wrong";
            }
        }

        static void Main(string[] args)
        {

            while (true)
            {
                int a, b, c;
                string a1, b1, c1, a2, b2, b3;
                Console.Write("\n");
                Console.ForegroundColor = ConsoleColor.White;
                while (true)
                {
                    Console.WriteLine("请输入第1数:");
                    a1 = Console.ReadLine();
                    a2 = qwx(a1);
                    if (a2 == "right")
                    {
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
            }
        }
    }
}



[ 本帖最后由 wangnannan 于 2010-11-15 08:21 编辑 ]

出来混,谁不都要拼命的嘛。 。拼不赢?那就看谁倒霉了。 。有机会也要看谁下手快,快的就能赢,慢。 。狗屎你都抢不到。 。还说什么拼命?
2010-11-15 08:20
wanjua
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-11-15
收藏
得分:0 
~`
2010-11-15 12:52
快速回复:[求助]函数调用出错!
数据加载中...
 
   



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

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