| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付学习型 ASP/PHP/ASP.NET 主机 30元/年
高端软件开发 = 年薪十万不是梦赛孚耐:软件保护加密专家身份认证令牌USB KEY 
共有 233 人关注过本帖
标题:该类中的一个函数为什么在调用时找不到函数名
收藏  订阅  推荐  打印 
ld999
Rank: 2
等级:注册会员
帖子:146
积分:1720
注册:2007-4-11
该类中的一个函数为什么在调用时找不到函数名

using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.IO;

namespace zlsmis
{
    class ConfigManager
    {
        public static void SetValue(string AppKey, string AppValue)
        {
            XmlDocument xDoc = new XmlDocument();
            xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");
            XmlNode xNode;
            XmlElement xElem1;
            XmlElement xElem2;
            xNode = xDoc.SelectSingleNode("//appSettings");
            xElem1 = (XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']");
            if (xElem1 != null) xElem1.SetAttribute("value", AppValue);
            else
            {
                xElem2 = xDoc.CreateElement("add");
                xElem2.SetAttribute("key", AppKey);
                xElem2.SetAttribute("value", AppValue);
                xNode.AppendChild(xElem2);
            }
            xDoc.Save(System.Windows.Forms.Application.ExecutablePath + ".config");
        }
        public static string GetValue(string AppKey)
        {
            try
            {
                string AppKeyValue;
                AppKeyValue = System.Configuration.ConfigurationManager.AppSettings.Get(AppKey);
                return AppKeyValue;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public string ConfigGetValue(string strExecutablePath, string appKey)
        {
            XmlDocument xDoc = new XmlDocument();
            try
            {
                xDoc.Load(strExecutablePath + ".config");

                XmlNode xNode;
                XmlElement xElem;
                xNode = xDoc.SelectSingleNode("//appSettings");
                xElem = (XmlElement)xNode.SelectSingleNode("//add[@key='" + appKey + "']");
                if (xElem != null)
                    return xElem.GetAttribute("value");
                else
                    return "";
            }
            catch (Exception)
            {
                return "";
            }
        }

    }
}

我在其它表单中调用这个类里的函数,其他的函数都行,只是ConfigGetValue这个函数找不到。
调用时的代码:ConfigManager.    后面没有该函数,为什么?
搜索更多相关主题的帖子: 函数  该类  
2007-12-19 20:03
guoxhvip
Rank: 12Rank: 12Rank: 12
来自:聖西羅南看臺
等级:版主
威望:33
帖子:3954
积分:39108
注册:2006-10-8

ConfigManager是你的类名 这样只能调用该类的静态方法 要想调用非静态方法只能创建对象再.来调用

愛生活 && 愛編程
2007-12-19 21:27
ld999
Rank: 2
等级:注册会员
帖子:146
积分:1720
注册:2007-4-11

明白了
2007-12-19 22:40
ld999
Rank: 2
等级:注册会员
帖子:146
积分:1720
注册:2007-4-11

ConfigGetValue(string strExecutablePath, string appKey)
里面的参数,怎么用?
2007-12-19 22:47
ld999
Rank: 2
等级:注册会员
帖子:146
积分:1720
注册:2007-4-11

谢谢版主,我解决了。也深刻体会到了这种调用方法。
2007-12-20 09:08
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.046215 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved