zoukankan
html css js c++ java
取得程序设定的常用代码.
using
System;
using
System.Configuration;
namespace
HXBTools.Util
{
/**/
///
<summary>
///
Class1 的摘要说明。
///
</summary>
public
class
Config
{
public
Config()
{
//
//
TODO: 在此处添加构造函数逻辑
//
}
public
static
string
GetSettingString(
string
sKeyName,
string
sDefault)
{
string
s
=
ConfigurationSettings.AppSettings[sKeyName];
if
(s
==
null
)
{
return
sDefault;
}
else
{
return
s;
}
}
public
static
int
GetSettingInt(
string
sKeyName,
int
iDefault)
{
string
s
=
Config.GetSettingString(sKeyName,
null
);
if
(s
==
null
)
return
iDefault;
int
i;
try
{
i
=
int
.Parse(s);
return
i;
}
catch
{
return
iDefault;
}
}
public
static
long
GetSettingLong(
string
sKeyName,
long
lDefault)
{
string
s
=
Config.GetSettingString(sKeyName,
null
);
if
(s
==
null
)
return
lDefault;
long
l;
try
{
l
=
long
.Parse(s);
return
l;
}
catch
{
return
lDefault;
}
}
public
static
decimal
GetSettingDecimal(
string
sKeyName,
decimal
dcDefault)
{
string
s
=
Config.GetSettingString(sKeyName,
null
);
if
(s
==
null
)
return
dcDefault;
decimal
dc;
try
{
dc
=
decimal
.Parse(s);
return
dc;
}
catch
{
return
dcDefault;
}
}
public
static
DateTime GetSettingDateTime(
string
sKeyName, DateTime dtDefaule)
{
string
s
=
Config.GetSettingString(sKeyName,
null
);
if
(s
==
null
)
return
dtDefaule;
DateTime dt;
try
{
dt
=
DateTime.Parse(s);
return
dt;
}
catch
{
return
dtDefaule;
}
}
public
static
bool
GetSettingBool(
string
sKeyName,
bool
bDefault)
{
string
s
=
Config.GetSettingString(sKeyName,
null
);
if
(s
==
null
)
return
bDefault;
switch
(s.Trim().ToLower())
{
case
"
true
"
:
case
"
真
"
:
case
"
是
"
:
case
"
1
"
:
case
"
yes
"
:
case
"
ok
"
:
case
"
-1
"
:
return
true
;
case
"
false
"
:
case
"
0
"
:
case
"
假
"
:
case
"
否
"
:
case
"
不
"
:
case
"
非
"
:
case
"
no
"
:
case
"
not
"
:
case
"
never
"
:
return
false
;
default
:
return
bDefault;
}
}
}
}
查看全文
相关阅读:
寒假记录六
寒假记录5
寒假记录4
寒假记录3
寒假记录2
寒假记录1
hive数据库课堂测试
第一周
个人总结
课程总结
原文地址:https://www.cnblogs.com/haoxiaobo/p/89932.html
最新文章
字符编码总结
SpringAOP理解
Spring配置文件详解
面向对象设计原则
Spring常用注解
Spring IOC(1)
SpringMVC学习总结1
JPA Annotation注解
2.MyBatis对数据库单表的增删查改
1.MyBatis所需要的配置文件
热门文章
HTML5--关于Web Worker
HTML5--关于Geolocalition(地理定位)
HTML5--Canvas
HTML5--关于音频和视频
HTML5-关于表单
DOM
BOM
正则表达式
JQuery中的动画效果
JQuery中的DOM操作
Copyright © 2011-2022 走看看