public static string  GetConfigStr(string Key)
{
//获取网站配置字段的键值
System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
string ConfigStr=((string)(configurationAppSettings.GetValue(Key, typeof(string))));
return ConfigStr.Trim();
// }
请问其中的.GetValue(Key, typeof(string)怎么理解啊?typeof(string)是什么意思?为什么()里面是个string?

解决方案 »

  1.   

    返回System.String类型的Type对象
    相当于   
    Object.GetType()
      

  2.   

    这是针对web.config中的结点取值,.net中提供了这么一个类.
    configurationAppSettings
    该类又有这么一个方法getvalue,表示根据"键"取"值";
    WEB.CONFIG中存储的都是键值对。TYPE(STRING)返回类型就是string类型
      

  3.   

    那既然后面TYPE(STRING)返回类型是string了,那前面干吗还用再强制装换string类型呢?
      

  4.   

    第二行,用的着强制转换为string吗?它本身不就是string吗?
      

  5.   

    configurationAppSettings.GetValue返回的是对象,要拆箱转换...
      

  6.   

    哦,这样啊,然后它下面又接着public static string  GetAccessConnStr(string MdbJetKey,string MdbPathKey)
    {
    //组合成数据库的连接字符串\
    return GetConfigStr(MdbJetKey)+ HttpRuntime.AppDomainAppPath.ToString()+GetConfigStr(MdbPathKey);
    // }
    其中GetConfigStr(MdbJetKey)
    这个 MdbJetKey 是啥意思呢?和AppsSettings里面的key键值名称不一样啊?<appSettings>
    <!--   此处显示用户应用程序和配置的属性设置。-->
    <!--   示例:<add key="settingName" value="settingValue"/> -->
    <add key="kysjMdbPath" value="css/#css 1.mdb" />
    <add key="kysjMdbJet" value="Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=123123;User ID=Admin;Data Source=" />
      </appSettings>那个这个MdbJetKey参数么意义呢?换个名字叫AB行吗?
      

  7.   

    还是取结点"键"对应的"值"没注意,每个ADD中都有key和value键值对?
      

  8.   


    我就是不明白这个MdbJetKey,它对应的谁和谁啊?
      

  9.   

    现在的问题是这个MdbJetKey,它对应的谁和谁啊?