c#

位置:IT落伍者 >> c# >> 浏览文章

数据库中与C#中的数据类型对照


发布日期:2023年04月06日
 
数据库中与C#中的数据类型对照

/// <summary>

/// 数据库中与C#中的数据类型对照

/// </summary>

/// <param name=type></param>

/// <returns></returns>

private string ChangeToCSharpType(string type)

{

string reval=stringEmpty;

switch(typeToLower())

{

case int:

reval= Int;

break;

case text:

reval= String;

break;

case bigint:

reval= Int;

break;

case binary:

reval= SystemByte[];

break;

case bit:

reval= Boolean;

break;

case char:

reval= String;

break;

case datetime:

reval= SystemDateTime;

break;

case decimal:

reval= SystemDecimal;

break;

case float:

reval= SystemDouble;

break;

case image:

reval= SystemByte[];

break;

case money:

reval= SystemDecimal;

break;

case nchar:

reval= String;

break;

case ntext:

reval= String;

break;

case numeric:

reval= SystemDecimal;

break;

case nvarchar:

reval= String;

break;

case real:

reval= SystemSingle;

break;

case smalldatetime:

reval= SystemDateTime;

break;

case smallint:

reval= Int;

break;

case smallmoney:

reval= SystemDecimal;

break;

case timestamp:

reval= SystemDateTime;

break;

case tinyint:

reval= SystemByte;

break;

case uniqueidentifier:

reval= SystemGuid;

break;

case varbinary:

reval= SystemByte[];

break;

case varchar:

reval= String;

break;

case Variant:

reval=Object;

break;

default:

reval= String;

break;

}

return reval;

}               

上一篇:.NET Compact Framework下的注册表开发

下一篇:C# 类中索引器的使用