当前位置:编程学习 > C#/ASP.NET >>

送分啦..!一个简单问题

LTP.Common.INIFile iniObject = new LTP.Common.INIFile(Server.MapPath("SystemINI/Param.ini"));
        #region $0101
        lbl1PV.Text = iniObject.IniReadValue("$0101", "ParamValue");
        lbl1SV.Text = iniObject.IniReadValue("$0101", "SetValue");
        lbl1DT.Text = iniObject.IniReadValue("$0101", "DataType");
        lbl1PD.Text = iniObject.IniReadValue("$0101", "ParamDesc");
        lbl1PU.Text = iniObject.IniReadValue("$0101", "ParamUnit");
        #endregion
        #region $0102
        lbl2PV.Text = iniObject.IniReadValue("$0102", "ParamValue");
        lbl2SV.Text = iniObject.IniReadValue("$0102", "SetValue");
        lbl2DT.Text = iniObject.IniReadValue("$0102", "DataType");
        lbl2PD.Text = iniObject.IniReadValue("$0102", "ParamDesc");
        lbl2PU.Text = iniObject.IniReadValue("$0102", "ParamUnit");
        #endregion
        #region $0103
        lbl3PV.Text = iniObject.IniReadValue("$0103", "ParamValue");
        lbl3SV.Text = iniObject.IniReadValue("$0103", "SetValue");
        lbl3DT.Text = iniObject.IniReadValue("$0103", "DataType");
        lbl3PD.Text = iniObject.IniReadValue("$0103", "ParamDesc");
        lbl3PU.Text = iniObject.IniReadValue("$0103", "ParamUnit");
        #endregion
        #region $0104
        lbl4PV.Text = iniObject.IniReadValue("$0104", "ParamValue");
        lbl4SV.Text = iniObject.IniReadValue("$0104", "SetValue");
        lbl4DT.Text = iniObject.IniReadValue("$0104", "DataType");
        lbl4PD.Text = iniObject.IniReadValue("$0104", "ParamDesc");
        lbl4PU.Text = iniObject.IniReadValue("$0104", "ParamUnit");
        #endregion --------------------编程问答--------------------
什么问题?  --------------------编程问答--------------------
鹅,貌似我也不会。。。 --------------------编程问答-------------------- 遍历ini文件下所有的Section和Key 并获取所有的值 而不是 一个个人肉写? --------------------编程问答-------------------- 额..怎么简化上面的代码..? --------------------编程问答-------------------- 什么问题 --------------------编程问答--------------------
无需简化,就这样挺好的

如果还有类似的话,再考虑优化 --------------------编程问答-------------------- ?啥问题~~ --------------------编程问答-------------------- 额..就想知道怎么简单的读取的..而不是这样一条一条的读取...! --------------------编程问答-------------------- * [NH-1255] - key-many-to-one && not-found
* [NH-1476] - filtering by key-many-to-one causes invalid sql
* [NH-1760] - Missing table join when use a criteria on key-many-to-one part of a Composite Id
* [NH-1785] - Invalid SQL generated for join on composite id using Criteria API 
* [NH-1858] - Problem with MsSql2000 and 2005 Dialects GetLimitString when using use_sql_comments=true
* [NH-1895] - delete-orphan mapping, NullReferenceException in DefaultDeleteEventListener.DeleteTransientEntity
* [NH-1898] - HQL query parser can't determine parameter type when using native sql function in hql query.
* [NH-1899] - SaveOrUpdateCopy throws InvalidCastException
* [NH-1902] - QBE don't set the '%' wildcards when using an other matchmode than Matchmode.Exact
* [NH-1904] - Protected properties and public properties cannot have the same name with different case
* [NH-1905] - Join used together with subquery generates wrong SQL
* [NH-1907] - IQuery.SetParameter<T> should use DetermineType
* [NH-1908] - Mishandling of filter parameters causes System.InvalidCastException
* [NH-1911] - Aggregate parameters in projection are not substituted
* [NH-1913] - AdoNet batcher not using CommandTimeout
* [NH-1914] - Collections with out native ID generation is not working
* [NH-1915] - CLONE -HQL AST-Parser: Null-Pointer Exception on Non-Exsistant Entity on Joins
* [NH-1917] - Not retrieving AUTO_INCREMENT identifier on MySQL because of connection closing
* [NH-1920] - Session Filters + collection + parametrized query = bug 
* [NH-1926] - Oracle: Schema update crashes
* [NH-1931] - NativeSQLQuerySpecification.Equals compares collections by reference
* [NH-1938] - No 'lower' call in sql-query in LikeExpression with 'ignorecae' = true
* [NH-1939] - Missing <param> element in NHibernate mapping schema.
* [NH-1941] - Custom Enum-String mapping is not written to SQL statement
* [NH-1948] - Hibernate mapping file does not allow a value of 0 for the "scale" attribute of the "property" element
* [NH-1959] - Adding/Removing items to idbag in one transaction causes KeyNotFoundException
* [NH-1963] - System.InvalidCastException on cacheable query with byte array query parameter
* [NH-1964] - Byte array truncation to a length of 8000
* [NH-1969] - Criteria API does not handle property of type "System.Type" correctly
* [NH-1973] - DateTime sent to dataase is not accurate to millisecond
* [NH-1979] - cast and parameter combination in HQL fails to parse
* [NH-1983] - Blobs and Clobs with Sql Server CE
* [NH-1985] - NHibernate is allowing deletion of immutable objects
* [NH-1987] - MultiQuery does not update statistics
* [NH-1990] - Subquery filter parameters are not set as variables in SQL
* [NH-1992] - BasicFormatter throws exceptions for certain types of data
* [NH-1997] - Original exception information lost when error occurs NHibernate.Engine.TransactionHelper.Work.DoWork
* [NH-2000] - Problem when calling ISession.GetEnableFIilter with a not enabled filter name
* [NH-2003] - IsNullable property is not set properly in ClassIdBinder.cs

--------------------编程问答--------------------
引用 3 楼 tchjl2007 的回复:
遍历ini文件下所有的Section和Key 并获取所有的值 而不是 一个个人肉写?


遍历+1 --------------------编程问答-------------------- 什么问题啊 --------------------编程问答-------------------- --------------------编程问答-------------------- 你这是winForm编程吗?是的话,你可以吧上面那些TextBox的tag属性在界面里面设置一下
如lbl1PV的tag设置为$0101-ParamValue,lbl1SV的tag设置为$0101-SetValue.....
然后再来做遍历
foreach (Control con in this.Controls)
{
    if (con.GetType().ToString() == "System.Web.UI.WebControls.TextBox")//如果是编辑框
    {
       TextBox txt = (TextBox)con;
       if (txt.tag == null) continue;
       string[] str = System.Text.RegularExpressions.Regex.Split(txt.tag, @"['-']+");//按“-”切割字符串
           txt.Text = = iniObject.IniReadValue(str[0], str[1]);
    }
} --------------------编程问答-------------------- 单独写个方法 
lblXXX.Text = iniObject.IniReadValue("XXX","value")包起来
外边弄个循环每次把键值$0101 $0102 
$0103 $0104传进去
--------------------编程问答-------------------- asp.net(C#)中.
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,