苹果6s6splus可以人像模式吗在哪里

本帖子已过去太久远了,不再提供回复功能。.NET读取config配置文件方法的总结——有疑求解?
.NET读取config配置文件方法的总结——有疑求解?
18:30:00来源:
1,在MSDN中对于配置文件的定义:
配置文件是可以按需要更改的 XML 文件。 开发人员可以使用配置文件来更改设置,而不必重编译应用程序。 管理员可以使用配置文件来设置策略,以便影响应用程序在计算机上运行的方式。
在我们编程的时候经常有一些字符串需要改变,例如:数据库连接字符串,设置分页时每页的记录数量。这时候我们就不能再去打开程序,或者找到cs或者aspx文件,然后记事本打开,再改写为自己需要的值。就可达到预期的效果。
2,配置文件的格式及模式:
是.Net自带的两种Winform中是app.config,web中是Web.config。
在config配置文件中。.Net framework 已经为它规定了一定的模式如下:
&configuration&
&configSections&&!--配置节声明区域,包括配置节和命名空间声明--&
&section name="" type=""/&&!--配置节声明--&
&/configSections&
&appSettings&
&add key="" value=""/&&!--预定义配置节--&
&/appSettings&
&/configuration&
3,配置文件中appSettings节的配置文件及访问方法
&configuration&
&appSettings&
&add key="SQLCONNECTIONSTRING" value="Data Source=DataBase=UID=PWD=123"/&
&/appSettings&
&/configuration&
在后台读取配置节中的字符串时有多种读法
简单的是调用System.Configuration后,直接读取(这种方法只可以读取)
然后string str=ConfigurationSettings.AppSettings["strconn"]
当然也可以将配置文件转化为xml文档,然后读取
XmlDocument doc = new XmlDocument();
string strFileName = AppDomain.CurrentDomain.BaseDirectory.ToString() + "App.config";
doc.Load(strFileName);
XmlNodeList nodes = doc.GetElementsByTagName("add");
for (int i = 0; i & nodes.C i++)
XmlAttribute att = nodes[i].Attributes["key"];
if (att.Value == "SQLCONNECTIONSTRING")
att = nodes[i].Attributes["value"];
string str=att.V
根据xml文档的节点是否是和设定的一样,读取配置文件。
4,自定义配置节的配置和读取方式(转自百度知道)
&configSections&
&section name="Test1" type="System.Configuration.SingleTagSectionHandler"/&
&/configSections&
section:声明新配置节,可创建配置节。name:自定义配置节的名称。type:自定义配置节的类型。主要包括一下三种:
System.Configuration.SingleTagSectionHandler
System.Configuration.DictionarySectionHandler
System.Configuration.NameValueSectionHandler
下面看个例子:
&?xml version="1.0" encoding="utf-8" ?&
&configuration&
&configSections&
&section name="Test1" type="System.Configuration.SingleTagSectionHandler"/&
&section name="Test2" type="System.Configuration.DictionarySectionHandler"/&
&section name="Test3" type="System.Configuration.NameValueSectionHandler" /&
&/configSections&
&Test1 setting1="Hello" setting2="World"/&
&add key="Hello" value="World" /&
&add key="Hello" value="World" /&
&/configuration&
下面是访问这三个配置节
//访问配置节Test1的方法1
System.Collections.IDictionary IDTest1 = (System.Collections.IDictionary)ConfigurationSettings.GetConfig("Test1");
label1.Text = (string)IDTest1["setting1"];
label2.Text = (string)IDTest1["setting2"];
//访问配置节Test1的方法2
string[] values1=new string[IDTest1.Count];
IDTest1.Values.CopyTo(values1,0);
label3.Text = values1[1].ToString();
label4.Text = values1[0].ToString();
//访问配置节Test2
System.Collections.IDictionary IDTest2 = (System.Collections.IDictionary)ConfigurationSettings.GetConfig("Test2");
string[] keys=new string[IDTest2.Keys.Count];
string[] values=new string[IDTest2.Keys.Count];
IDTest2.Keys.CopyTo(keys,0);
IDTest2.Values.CopyTo(values,0);
label5.Text = keys[0].ToString();
label6.Text = values[0].ToString();
//访问配置节Test3
System.Collections.Specialized.NameValueCollection nc=(System.Collections.Specialized.NameValueCollection)ConfigurationSettings.GetConfig("Test3");
label7.Text = nc.AllKeys[0].ToString();
label8.Text = "World";
//输出Hello World
通过上面的代码我们可以看出,不同的type通过GetConfig返回的类型不同,具体获得配置内容的方式也不一样。
只知其然,不知其所以然。求答案。
上面是我写的程序。然后有很多疑问:
1,对于访问配置节1的第二种方法,
label3.Text = values1[1].ToString();
label4.Text = values1[0].ToString();
读取数组的第二个是Hello,数组的第一个是World,有些搞不懂,难道将IDTest1复制到values1是反正复制的?
测试也是按上面的程序才对。求解?
2,配置节2中
IDTest2.Keys.CopyTo(keys,0);
IDTest2.Values.CopyTo(values,0);
都是将IDTest2复制到数组中,怎么keys和values不一样呢?求解
3,配置节3中label7.Text = nc.AllKeys[0].ToString()获取的是所有key的值,只取得Hello可以理解
问一下有没办法取得value值经检测你所在的网络可能存在爬虫,因资源限制,我们只能拒绝你的请求。
如果你是推酷的用户,可以以继续访问使用。
如有疑问,可将IP信息发送到
请求解封。

我要回帖

更多关于 iphone6s有人像模式吗 的文章

 

随机推荐