| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1146 人关注过本帖
标题:该类中的一个函数为什么在调用时找不到函数名
只看楼主 加入收藏
ld999
Rank: 1
等 级:新手上路
帖 子:147
专家分:0
注 册:2007-4-11
收藏
 问题点数:0 回复次数:4 
该类中的一个函数为什么在调用时找不到函数名
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using

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: 8Rank: 8
来 自:聖西羅南看臺
等 级:贵宾
威 望:44
帖 子:4052
专家分:135
注 册:2006-10-8
收藏
得分:0 
ConfigManager是你的类名 这样只能调用该类的静态方法 要想调用非静态方法只能创建对象再.来调用

愛生活 && 愛編程
2007-12-19 21:27
ld999
Rank: 1
等 级:新手上路
帖 子:147
专家分:0
注 册:2007-4-11
收藏
得分:0 
明白了
2007-12-19 22:40
ld999
Rank: 1
等 级:新手上路
帖 子:147
专家分:0
注 册:2007-4-11
收藏
得分:0 
ConfigGetValue(string strExecutablePath, string appKey)
里面的参数,怎么用?
2007-12-19 22:47
ld999
Rank: 1
等 级:新手上路
帖 子:147
专家分:0
注 册:2007-4-11
收藏
得分:0 
谢谢版主,我解决了。也深刻体会到了这种调用方法。
2007-12-20 09:08
快速回复:该类中的一个函数为什么在调用时找不到函数名
数据加载中...
 
   



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

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