·您现在的位置: 云翼网络 >> 文章中心 >> 网站建设 >> 网站建设开发 >> ASP.NET网站开发 >> 常见问题解决方法

常见问题解决方法

作者:佚名      ASP.NET网站开发编辑:admin      更新时间:2022-07-23

常见问题解决方法

1.通过枚举获取属性的方法

///<summary>

/// 获取枚举属性

///</summary>

///<param name="e"></param>

///<returns></returns>

publicstaticString GetEnumDesc(Enum e)

{

FieldInfo EnumInfo = e.GetType().GetField(e.ToString());

DescriptionAttribute[] EnumAttributes = (DescriptionAttribute[])EnumInfo.

GetCustomAttributes(typeof(DescriptionAttribute), false);

if (EnumAttributes.Length > 0)

{

return EnumAttributes[0].Description;

}

return e.ToString();

}

publicclassEnumStringHelper

{

publicstaticstring getString(object o)

{

Type t = o.GetType();

string s = o.ToString();

DescriptionAttribute[] os = (DescriptionAttribute[])t.GetField(s).GetCustomAttributes(typeof(DescriptionAttribute), false);

if (os != null&& os.Length == 1)

{

return os[0].Description.ToString();

}

return s;

}

}

2.拷贝对象数据

///<summary>

/// 深拷贝

///</summary>

///<param name="value">原拷贝对象</param>

///<returns>新拷贝对象</returns>

T DeepCopy<T>(T value)

{

T temp = default(T);

try

{

MemoryStream ms = newMemoryStream();

BinaryFormatter bf = newBinaryFormatter();

bf.Serialize(ms, value);

ms.Seek(0, 0);

temp = (T)bf.Deserialize(ms);

ms.Close();

}

catch

{ }

return temp;

}

3.重置sql表自增ID

dbcc checkident(‘表名’,reseed,0)

4.更改powerDesigner的默认数据库引擎(Unable to list the table)

更改powerDesigner的默认数据库引擎(Unable to list the table的解决办法。)

菜单 database -〉 change current dbms 。本文地址

用PowerDesigner逆向数据库工程时”Unable to list the table"错误的解决方法。

“SP_DBCMPTLEVEL”存储过程来正确设置数据库的版本兼容。知道原因后解决故障就很简单了,打开企业管理器,输入“EXEC SP_DBCMPTLEVEL 'DataBaseName', '90'; GO ”并执行,执行成功后,重新逆向工程就可以了。 PS: SP_DBCMPTLEVEL 存储过程一共需要两个参加,第一个参数为数据库名,在上面的例子中我的数据库名为“PMS”,第二个参数为想要设置的sql server版本号,其对应关系如下 80 = SQL Server 2000 90 = SQL Server 2005 100 = SQL Server 2008 ,在上面的例子中由于我想和sql server 2005兼容,所以设置版本号为90。

5.普通笔记

  1. partial修饰符可以让一个类里的方法放在不同的文件中。
  2. test1.cs

publicpartialclassTest

{

publicvoid one()

{

}

  1. }
  2. Test2.cs

publicpartialclassTest

{

publicvoid Two()

{

}

  1. }

  1. 结构与类的区别是它们在内 存中的 存储方式、 访问 方式(类 是存储在堆【 heap,上 的引用类型,而

结构是 存储在栈上 的 值类型)和 它们的一些特征(如 结构不支持继承。 较小的 数据类型使 用结

构可提高性能。 但在语法上,结 构与类非常相似,主 要的区别是使用关键字 struct代 替 dass来 声明结构。

  1. ref引用传递必须初始化,out可以不用初始化。

static void someFunction(out int i)

(

i= 100;

I

public static int Main()

(

int i // note how i ig dec△ ared but not initia△ ized.

someFunCtion(out i)`

C0nsole.WriteLine(i)`

Return

  1. var关 键字,它 用于表示隐式类型化的变量
  2. Virtual方法(虚方法)

virtual 关键字用于在基类中修饰方法。virtual的使用会有两

种情况:

情况1:在基类中定义了virtual方法,但在派生类中没有重写

该虚方法。那么在对派生类实例的调用中,该虚方法使用的是基

类定义的方法。

情况2:在基类中定义了virtual方法,然后在派生类中使用

  • override重写该方法。那么在对派生类实例的调用中,该虚方法

使用的是派生重写的方法。

二、Abstract方法(抽象方法)

abstract关键字只能用在抽象类中修饰方法,并且没有具体的

实现。抽象方法的实现必须在派生类中使用override关键字来实

6.Js 拖动代码

var Layer='';

var iLayerMaxNum=1000;

var a;

document.onmouseup=me;

document.onmousemove = ms;

var b;

var c;

function Move(Object,event){

Layer=Object.id;

if(document.all){

document.getElementById(Layer).setCapture();

b=event.x-document.getElementById(Layer).style.pixelLeft;

c=event.y-document.getElementById(Layer).style.pixelTop;

}elseif(window.captureEvents){

window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);

b=event.layerX;

c = event.layerY + 100;

};

if(Layer!="Layer"+a){

document.getElementById(Layer).style.zIndex=iLayerMaxNum;

iLayerMaxNum=iLayerMaxNum+1;

}

}

function ms(d){

if(Layer!=''){

if(document.all){

document.getElementById(Layer).style.left=event.x-b;

document.getElementById(Layer).style.top=event.y-c;

}elseif(window.captureEvents){

document.getElementById(Layer).style.left=(d.clientX-b)+"px";

document.getElementById(Layer).style.top=(d.clientY-c)+"px";

}

}

}

function me(d){

if(Layer!=''){

if(document.all){

document.getElementById(Layer).releaseCapture();

Layer='';

}elseif(window.captureEvents){

window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);

Layer='';

}

}

}

function Close(n){

var e='Layer'+n;

document.getElementById(e).style.display='none';

Hide();

}

//显?示º?高?亮¢¨¢的Ì?字Á?条¬?

function Show(n){

var e=document.getElementById('Layer'+n);

if (e){

e.style.zIndex =iLayerMaxNum+1;

document.getElementById("mask").style.display = "block";

document.getElementById("mask").style.zIndex = iLayerMaxNum;

var size = getPageSize();

document.getElementById("mask").style.width = size[0];

document.getElementById("mask").style.height = size[1];

}else{

alert("对?不?起e,ê?您¨²搜?索¡Â的Ì?字Á?条¬?不?存ä?在¨²!ê?");

history.back(1);

}

}

function Hide(){

document.getElementById("mask").style.display = "none";

iLayerMaxNum=iLayerMaxNum+2;

}

function getPageSize(){

var de = document.documentElement;

var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;

var h = window.innerHeight || self.innerHeight || document.body.clientHeight || (de&&de.clientHeight);

arrayPageSize = new Array(w,h);

return