C#清除页面缓存
private void SetPageNoCache()
{
Response.Buffer = true;
Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1);
Response.Expires = 0;
Response.CacheControl = "no-cache";
Response.AddHeader("Pragma", "No-Cache");
}
(1) Response.Buffer = true;
Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1);
Response.Expires = 0;
&nbs ......
(1)string是引用类型:
string是引用类型,这就是说string在堆上保存数据,而在栈中存储的是对象地址,在理解string类型特性时首先需要记住这点。只不过与其它一些引用类型相比,它又有一些比较特殊的特性,比如下面的这些:
(2)string是不可变的(immutable):
string的这一特性是指,对于已有的一个string对象,当你修改它时,实际是重新创建了一个符合你要求的string对象。我通过以下的例子进行演示:
static void Main(string[] args)
{
string x = "should it matter";
x = x + " ?"; //breakpoint (1)
}//breakpoint (2)
F5运行至breakpoint (1)处,在即时窗口中执行以下sos调试命令(关于sos调试扩展,可以参见《VS 2005中Sos调试扩展简介》):
!load sos.dll
extension C:"WINDOWS"Microsoft.NET"Framework"v2.0.50727"sos.dll loaded
!clrstack -a
PDB symbol for mscorwks.dll not loaded
OS Thread Id: 0x1508 (5384)
ESP EIP
0012f440 012f009f ConsoleApplication1.Program.Main(System.String[])
PARAMETERS:
& ......
利用WM_COPYDATA在应用程序间传递数据很简单,开销也小
一、传递数据部分
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace ThreeTorches
{
public struct Copydatastruct
{
public IntPtr dwData;
public int cbData;
public IntPtr lpData;
}
public static class XianaoMessage
{
[DllImport("User32.dll", EntryPoint = "FindWindow")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", EntryPoint = "FindWindowEx")]
public static ext ......
1.c++的到处函数只要在函数申明的时候加个导出关键字就可以了
2.参数类型问题,
一般的c++中char * 对应 c#中的string
而c++中 char **类型的参数对应c#中 ref string 这种一般都是用来返回字符串的!
3.函数入口问题,一般会出现 "找不到入口点" 这个问题不是由你引起的,而是系统自己把名字改了,改成什么样的名字建议你用eXeScope 打开dll看看里面的全称,比如我从网上下载的一个dll的导出方法列表
导出, CryptoPP32.dll
序列 地址 名字
00000001 100489D0 ?Base64DecodeFile@CryptoPP32@@YA_NPBD0@Z
00000002 1004FAC0 ?Base64DecodeString@CryptoPP32@@YA_NPBDPAPAD@Z
00000003 100488E0 ?Base64EncodeFile@CryptoPP32@@YA_NPBD0@Z
00000004 1004F960 ?Base64EncodeString@CryptoPP32@@YA_NPBDPAPAD@Z
00000005 10045EB0 ?FreeString@CryptoPP32@@YAXPAD@Z
00000006 10048800 ?GunzipFile@CryptoPP32@@YA_NPBD0@Z
00000007 10048720 ?GzipFile@CryptoPP32@@YA_NPBD0H@Z
00000008 10048E30 ?HMAC_SHA1_DecryptFile@CryptoPP32@@YA_NPBD00@Z
00000009 10048B90 ?HMAC_SHA1_DecryptString@CryptoPP32@@YA_NPBD0PAPAD@Z
0000000A 10048D40 ?HMAC_SHA1_EncryptFile@ ......
1.c++的到处函数只要在函数申明的时候加个导出关键字就可以了
2.参数类型问题,
一般的c++中char * 对应 c#中的string
而c++中 char **类型的参数对应c#中 ref string 这种一般都是用来返回字符串的!
3.函数入口问题,一般会出现 "找不到入口点" 这个问题不是由你引起的,而是系统自己把名字改了,改成什么样的名字建议你用eXeScope 打开dll看看里面的全称,比如我从网上下载的一个dll的导出方法列表
导出, CryptoPP32.dll
序列 地址 名字
00000001 100489D0 ?Base64DecodeFile@CryptoPP32@@YA_NPBD0@Z
00000002 1004FAC0 ?Base64DecodeString@CryptoPP32@@YA_NPBDPAPAD@Z
00000003 100488E0 ?Base64EncodeFile@CryptoPP32@@YA_NPBD0@Z
00000004 1004F960 ?Base64EncodeString@CryptoPP32@@YA_NPBDPAPAD@Z
00000005 10045EB0 ?FreeString@CryptoPP32@@YAXPAD@Z
00000006 10048800 ?GunzipFile@CryptoPP32@@YA_NPBD0@Z
00000007 10048720 ?GzipFile@CryptoPP32@@YA_NPBD0H@Z
00000008 10048E30 ?HMAC_SHA1_DecryptFile@CryptoPP32@@YA_NPBD00@Z
00000009 10048B90 ?HMAC_SHA1_DecryptString@CryptoPP32@@YA_NPBD0PAPAD@Z
0000000A 10048D40 ?HMAC_SHA1_EncryptFile@ ......
1.c++的到处函数只要在函数申明的时候加个导出关键字就可以了
2.参数类型问题,
一般的c++中char * 对应 c#中的string
而c++中 char **类型的参数对应c#中 ref string 这种一般都是用来返回字符串的!
3.函数入口问题,一般会出现 "找不到入口点" 这个问题不是由你引起的,而是系统自己把名字改了,改成什么样的名字建议你用eXeScope 打开dll看看里面的全称,比如我从网上下载的一个dll的导出方法列表
导出, CryptoPP32.dll
序列 地址 名字
00000001 100489D0 ?Base64DecodeFile@CryptoPP32@@YA_NPBD0@Z
00000002 1004FAC0 ?Base64DecodeString@CryptoPP32@@YA_NPBDPAPAD@Z
00000003 100488E0 ?Base64EncodeFile@CryptoPP32@@YA_NPBD0@Z
00000004 1004F960 ?Base64EncodeString@CryptoPP32@@YA_NPBDPAPAD@Z
00000005 10045EB0 ?FreeString@CryptoPP32@@YAXPAD@Z
00000006 10048800 ?GunzipFile@CryptoPP32@@YA_NPBD0@Z
00000007 10048720 ?GzipFile@CryptoPP32@@YA_NPBD0H@Z
00000008 10048E30 ?HMAC_SHA1_DecryptFile@CryptoPP32@@YA_NPBD00@Z
00000009 10048B90 ?HMAC_SHA1_DecryptString@CryptoPP32@@YA_NPBD0PAPAD@Z
0000000A 10048D40 ?HMAC_SHA1_EncryptFile@ ......
问:
1.如何在JavaScript访问C#函数?
2.如何在JavaScript访问C#变量?
3.如何在C#中访问JavaScript的已有变量?
4.如何在C#中访问JavaScript函数?
问题1答案如下:
javaScript函数中执行C#代码中的函数:
方法一:1、首先建立一个按钮,在后台将调用或处理的内容写入button_click中;
2、在前台写一个js函数,内容为document.getElementById("btn1").click();
3、在前台或后台调用js函数,激发click事件,等于访问后台c#函数;
方法二:1、函数声明为public
后台代码(把public改成protected也可以)
public string ss()
{
return("a");
}
2、在html里用<%=fucntion()%>可以调用
前台脚本
< language=java>
var a = "<%=ss()%>";
alert(a);
</>
方法三:1、< language="java">
<!--
function __doPostBack(eventTarget, eventArgument)
{
var theForm = document.Form1; //指runat=server的form
theForm.__EVENTTARGET.value = eventTarget;
thefrom.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
-->
</>
<input id="Button1" type="button" name="Button1" value="按钮" ......
问:
1.如何在JavaScript访问C#函数?
2.如何在JavaScript访问C#变量?
3.如何在C#中访问JavaScript的已有变量?
4.如何在C#中访问JavaScript函数?
问题1答案如下:
javaScript函数中执行C#代码中的函数:
方法一:1、首先建立一个按钮,在后台将调用或处理的内容写入button_click中;
2、在前台写一个js函数,内容为document.getElementById("btn1").click();
3、在前台或后台调用js函数,激发click事件,等于访问后台c#函数;
方法二:1、函数声明为public
后台代码(把public改成protected也可以)
public string ss()
{
return("a");
}
2、在html里用<%=fucntion()%>可以调用
前台脚本
< language=java>
var a = "<%=ss()%>";
alert(a);
</>
方法三:1、< language="java">
<!--
function __doPostBack(eventTarget, eventArgument)
{
var theForm = document.Form1; //指runat=server的form
theForm.__EVENTTARGET.value = eventTarget;
thefrom.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
-->
</>
<input id="Button1" type="button" name="Button1" value="按钮" ......
[SerializableAttribute]
[ComVisibleAttribute(true)]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDual)]
public class Object
1 public virtual bool Equels (Object)
2 public static bool static Equels (Object,Object)
默认实现为对引用类型使用引用相等,对值类型使用二进制按位相等。引用相等性是指进行比较的多个对象引用所引用的是同一个对象。按位相等性是指进行比较的多个对象具有相同的二进制表示形式。派生类可以通过继承实现值相等。
派生equals必须遵循的几个原则
1 x.equals(x)必须为true;,2 x.equals(y)和y.equals(x)必须返回相同值 3 如果x,y都是NaN,则x.Equals(y)返回true.
4 x.equals(z)=true,当且仅当x.equals(y)=true&&y.Equals(z)=true 5 x.Equals(Null)为false 6 不改变x,y指向的对象,x.Equals(y)返回值不变
Equals的实现不可以引发异常,实现IComparable类型,必须重写Equals.重写Equals必须也重写GetHashCode.
3 public virtual int GetHashCode()
特点: 如果两个对象相等,则hashcode必须相等。反过来不一定成立
4 public Type GetType()
表示当前实例的确切运行时类型
5 public static bool ReferenceEq ......