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;
}
}
}
}
查看全文
相关阅读:
哈希算法是怎么实现的
高并发下日志组件的各种实现方式
算法是如何影响程序编码方式的
<<.NET B/S 架构实践>> 几种概念区别
如何扩大系统盘空间
区别:ASP.NET MVC的Model、DTO、Command
能递归检查DataAnnotations的验证函数
NuGet的本地服务器安装与Package的发布(呕吐)
多模块分布式系统的简单服务访问
多模块后带来的问题解决方法
原文地址:https://www.cnblogs.com/haoxiaobo/p/89932.html
最新文章
WPF 仿苹果系统规划
WPF窗体自适应分辨率
c++类成员函数后边加const是为什么?
python3 zip压缩文件压缩多个不同文件夹内的文件方法
Mysql 查询decimal 引号‘’增加精度
python3二元Logistics Regression 回归分析(LogisticRegression)
职场该注意的潜规则
mysql搭建主从
mariadb 10.1.26 二进制包安装笔记
kali 无法使用ifconfig等常用命令
热门文章
将自己写的windows服务加入到windows集群中
内部通信服务Factory(WCF)
消息队列工具类(MSMQ)
My ajaxwrapper tool
重构JS代码
一致性环Hash算法.NET实现
高并发下的Id生成器
读写分离子系统
散列算法是怎么实现的
A2D Framework
Copyright © 2011-2022 走看看