校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > asp.net 數(shù)據(jù)類型轉(zhuǎn)換類代碼

asp.net 數(shù)據(jù)類型轉(zhuǎn)換類代碼

熱門標(biāo)簽:浙江外呼系統(tǒng)怎么安裝 地圖標(biāo)注多個行程 上海楊浦怎么申請申請400電話 云南外呼電銷機器人系統(tǒng) 廈門商鋪地圖標(biāo)注 山西防封卡電銷卡套餐 海外地圖標(biāo)注門市標(biāo) 陜西人工外呼系統(tǒng)哪家好 銅川小型外呼系統(tǒng)運營商
復(fù)制代碼 代碼如下:

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace TypeClass
{
public class TypeParse
{
/// summary>
/// 判斷對象是否為Int32類型的數(shù)字
/// /summary>
/// param name="Expression">/param>
/// returns>/returns>
public static bool IsNumeric(object Expression)
{
if (Expression != null)
{
int intVal;
return int.TryParse(Expression.ToString(), out intVal);
}
return false;
}
public static bool IsDouble(object Expression)
{
if (Expression != null)
{
double doubleVal;
return double.TryParse(Expression.ToString(), out doubleVal);
}
return false;
}
/// summary>
/// string型轉(zhuǎn)換為bool型
/// /summary>
/// param name="strValue">要轉(zhuǎn)換的字符串/param>
/// param name="defValue">缺省值/param>
/// returns>轉(zhuǎn)換后的bool類型結(jié)果/returns>
public static bool StrToBool(object Expression, bool defValue)
{
if (Expression != null)
{
bool boolValue;
if (bool.TryParse(Expression.ToString(), out boolValue))
return boolValue;
else
return defValue;
}
return defValue;
}
/// summary>
/// 將對象轉(zhuǎn)換為Int32類型
/// /summary>
/// param name="strValue">要轉(zhuǎn)換的字符串/param>
/// param name="defValue">缺省值/param>
/// returns>轉(zhuǎn)換后的Int32類型結(jié)果/returns>
public static int StrToInt(object Expression, int defValue)
{
if (Expression != null)
{
int intValue;
if (int.TryParse(Expression.ToString(), out intValue))
return intValue;
else
return defValue;
}
return defValue;
}
/// summary>
/// string型轉(zhuǎn)換為float型
/// /summary>
/// param name="strValue">要轉(zhuǎn)換的字符串/param>
/// param name="defValue">缺省值/param>
/// returns>轉(zhuǎn)換后的float類型結(jié)果/returns>
public static float StrToFloat(object strValue, float defValue)
{
if (strValue != null)
{
float floatValue;
if (float.TryParse(strValue.ToString(), out floatValue))
return floatValue;
else
return defValue;
}
return defValue;
}
/// summary>
/// string型轉(zhuǎn)換為Decimal型
/// /summary>
/// param name="strValue">要轉(zhuǎn)換的字符串/param>
/// param name="defValue">缺省值/param>
/// returns>轉(zhuǎn)換后的Decimal類型結(jié)果/returns>
public static Decimal StrToDecimal(object strValue, Decimal defValue)
{
if (strValue != null)
{
Decimal decimalValue;
if (Decimal.TryParse(strValue.ToString(), out decimalValue))
return Math.Round(decimalValue,2);
else
return defValue;
}
return defValue;
}
/// summary>
/// string型轉(zhuǎn)換為datetime型
/// /summary>
/// param name="strValue">要轉(zhuǎn)換的字符串/param>
/// param name="defValue">缺省值/param>
/// returns>轉(zhuǎn)換后的datetime類型結(jié)果/returns>
public static DateTime StrToDateTime(object strValue, DateTime defValue)
{
if (strValue != null)
{
DateTime DateTimeValue;
if (DateTime.TryParse(strValue.ToString(), out DateTimeValue))
return DateTimeValue;
else
return defValue;
}
return defValue;
}
/// summary>
/// 判斷給定的字符串?dāng)?shù)組(strNumber)中的數(shù)據(jù)是不是都為數(shù)值型
/// /summary>
/// param name="strNumber">要確認(rèn)的字符串?dāng)?shù)組/param>
/// returns>是則返加true 不是則返回 false/returns>
public static bool IsNumericArray(string[] strNumber)
{
if (strNumber == null)
{
return false;
}
if (strNumber.Length 1)
{
return false;
}
foreach (string id in strNumber)
{
if (!IsNumeric(id))
{
return false;
}
}
return true;
}
}
}

標(biāo)簽:信陽 許昌 孝感 常州 自貢 西雙版納 朔州 萊蕪

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《asp.net 數(shù)據(jù)類型轉(zhuǎn)換類代碼》,本文關(guān)鍵詞  asp.net,數(shù)據(jù),類型,轉(zhuǎn)換,類,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《asp.net 數(shù)據(jù)類型轉(zhuǎn)換類代碼》相關(guān)的同類信息!
  • 本頁收集關(guān)于asp.net 數(shù)據(jù)類型轉(zhuǎn)換類代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 山丹县| 永福县| 巴南区| 蒙山县| 锦屏县| 镇原县| 姚安县| 平乡县| 曲麻莱县| 台中市| 平顺县| 兴安盟| 烟台市| 永济市| 莆田市| 宁德市| 绥滨县| 曲周县| 香河县| 时尚| 进贤县| 搜索| 高淳县| 桂东县| 山阴县| 扶风县| 浪卡子县| 阳信县| 井陉县| 福鼎市| 探索| 荔浦县| 万山特区| 石棉县| 徐闻县| 昭通市| 隆回县| 大安市| 鹰潭市| 东台市| 日喀则市|