Coding with .NET

Live with passion, coding with passion....

首页 新随笔 联系 订阅 管理
  16 Posts :: 3 Stories :: 117 Comments :: 0 Trackbacks

公告

最新评论

共6页: 1 2 3 4 5 6 下一页 
Re:漫谈asp.net 之二:Caching InterNationalBigMoth 2010-12-10 10:29  
我的系统及vs2005都是刚装的,运行项目就出错如下:
错误
您所请求的网址(URL)无法获取

--------------------------------------------------------------------------------

当尝试读取以下网址(URL)时: http://localhost:1641/Test3/

发生了下列的错误:

Access Denied.
拒绝访问
Access control configuration prevents your request from being allowed at this time. Please contact your service provider if you feel this is incorrect.
当前的存取控制设定禁止您的请求被接受,如果您觉得这是错误的,请与您网路服务的提供者联系。


本缓存服务器管理员:root



--------------------------------------------------------------------------------

Generated Tue, 26 Aug 2008 07:15:35 GMT by proxyA (squid/2.6.STABLE17)
re: ref 关键字的用法 沙加 2008-08-19 22:29  
对于引用类型,ref应该是都存在的, 但对于值类型,ref才有意义吧
re: ref 关键字的用法 zealylee 2007-08-25 18:03  
错了,能看出差别来,但是感觉不清晰。呵呵
re: ref 关键字的用法 zealylee 2007-08-25 18:01  
24 char i = 'a'; // variable must be initialized
25 TestRef(ref i); // the arg must be passed as ref
26 Console.WriteLine(i);
27 TestNoRef(i);
28 Console.WriteLine(i);

不知道你是否抄错了 msdn 上的东西,这样写是有问题的,看不出什么现象。

把 TestRef(ref i); 和 TestNoRef(i); 倒调一下看看情况怎么样?
re: 八皇后问题 Hunter37 2007-08-25 13:33  
我也来写一个batch file版的非递归算法。

@echo off
setlocal ENABLEDELAYEDEXPANSION

if "%~1" == "" (echo USAGE: queen.cmd ^<number^> & goto :EOF)
set /a _n=%~1
if %_n% lss 1 (echo No negitve number or zero & goto :EOF)

set /a _nv=%_n%*2-1

for /l %%i in (1,1,%_n%) do (
set _afj_%%i=0
set _anh_%%i=0
)

for /l %%i in (1,1,%_nv%) do (
set _afl_%%i=0
set _afr_%%i=0
)

set _count=0
set _i=1

:LOOP_I
if %_i% equ 0 goto :BREAK_I
if %_i% gtr %_n% (
set /a _count+=1

echo.
echo ========== !_count! ==========
for /l %%i in (1,1,%_n%) do (
set _echo=
for /f %%j in ('echo %%_anh_%%i%%') do set _k=%%j

for /l %%j in (1,1,%_n%) do (
if !_k! equ %%j (
set _echo=!_echo! x
) else (
set _echo=!_echo! .
)
)
echo !_echo!
)

set /a _i-=1
)

for /f %%i in ('echo %%_anh_%_i%%%') do set _j=%%i
set /a _l=%_j%-%_i%+%_n%
set /a _r=%_j%+%_i%-1

if %_j% neq 0 (
set _afj_%_j%=0
set _afl_%_l%=0
set _afr_%_r%=0
)

:LOOP_J

set /a _j+=1
set /a _l+=1
set /a _r+=1
if %_j% gtr %_n% (
set _anh_%_i%=0
set /a _i-=1
goto BREAK_J
)

for /f %%i in ('echo %%_afj_%_j%%%') do set _fj=%%i
for /f %%i in ('echo %%_afl_%_l%%%') do set _fl=%%i
for /f %%i in ('echo %%_afr_%_r%%%') do set _fr=%%i

if %_fj% equ 0 if %_fl% equ 0 if %_fr% equ 0 (
set _anh_%_i%=%_j%
set _afj_%_j%=1
set _afl_%_l%=1
set _afr_%_r%=1
set /a _i+=1
goto BREAK_J
)

goto LOOP_J
:BREAK_J

goto LOOP_I
:BREAK_I

echo.
echo Total = %_count%
我再补充一下吧,Bin目录权限可以继承父目录的权限,如果有单单拷贝一个*.dll文件过去的话,请注意也检查一下该dll的权限...这样此问题可以得到最终的解决...
高见!
re: ref 关键字的用法[未登录] KING 2007-05-28 19:44  
我也没学过C++
不错
re: Configuration Model in .Net 2.0 kmjacky 2006-03-03 01:49  
[ConfigurationCollection(typeof(MyCustomSec), AddItemName="CustomSection")]
public sealed class MyCustomSecColletions : ConfigurationElementCollection
{
private static readonly ConfigurationProperty _propCustomSections;
private static ConfigurationPropertyCollection _properties;

static MyCustomSecColletions()
{
_propCustomSections = new ConfigurationProperty(null, typeof(MyCustomSecColletions),
null, ConfigurationPropertyOptions.IsDefaultCollection);

_properties = new ConfigurationPropertyCollection();
_properties.Add(MyCustomSecColletions._propCustomSections);
}

protected override ConfigurationElement CreateNewElement()
{
return new MyCustomSec();
}

protected override object GetElementKey(ConfigurationElement element)
{
MyCustomSec cussec = (MyCustomSec)element;
if (cussec.ID == null)
{
return string.Concat(cussec.Corp, ":", cussec.User, ":", ((cussec.Default == null) ? string.Empty : cussec.Default));
}
else
{
return cussec.ID;
}
}

public override ConfigurationElementCollectionType CollectionType
{
get{ return ConfigurationElementCollectionType.BasicMap; }
}

protected override string ElementName
{
get { return "CustomSection"; }
}

public MyCustomSec this[int index]
{
get
{
return (MyCustomSec)BaseGet(index);
}
set
{

if (BaseGet(index) != null)
{
BaseRemoveAt(index);
}
BaseAdd(index, value);
}
}

public int IndexOf(MyCustomSec msc)
{
return BaseIndexOf(msc);
}

public void Add(MyCustomSec msc)
{
BaseAdd(msc);
// Add custom code here.
}

protected override void BaseAdd(ConfigurationElement element)
{
BaseAdd(element, false);
// Add custom code here.
}

public void Remove(MyCustomSec msc)
{
if (BaseIndexOf(msc) >= 0)
BaseRemove(msc.ID);
}

public void RemoveAt(int index)
{
BaseRemoveAt(index);
}

public void Remove(string id)
{
BaseRemove(id);
}

public void Clear()
{
BaseClear();
// Add custom code here.
}

protected override ConfigurationPropertyCollection Properties
{
get{ return MyCustomSecColletions._properties; }
}
}
re: Configuration Model in .Net 2.0 kmjacky 2006-03-03 01:49  

public sealed class MyCustomSec : ConfigurationElement
{
private static readonly ConfigurationProperty _id;
private static readonly ConfigurationProperty _corp;
private static ConfigurationPropertyCollection _properties;
private static readonly ConfigurationProperty _user;
private static readonly ConfigurationProperty _default;
//private static readonly ConfigurationElementProperty s_elemProperty;

static MyCustomSec()
{
//s_elemProperty = null;
_id = new ConfigurationProperty("id", typeof(string), "");
_corp = new ConfigurationProperty("corp", typeof(string), "");
_user = new ConfigurationProperty("user", typeof(string), "");
_default = new ConfigurationProperty("default", typeof(string), "");

_properties = new ConfigurationPropertyCollection();
_properties.Add(_id);
_properties.Add(_corp);
_properties.Add(_user);
_properties.Add(_default);
}

[ConfigurationProperty("id", DefaultValue = "", IsRequired = true, IsKey = true)]
public string ID
{
get{ return (string)base[MyCustomSec._id]; }
set{ base[MyCustomSec._id] = value; }
}

[ConfigurationProperty("corp", DefaultValue = "", IsRequired = true, IsKey = false)]
[StringValidator(InvalidCharacters = "~!@$%^&*()[]{}/;'\"|\\", MaxLength = 60)]
public string Corp
{
get{ return (string)base[MyCustomSec._corp]; }
set{ base[MyCustomSec._corp] = value; }
}

[ConfigurationProperty("user", DefaultValue = "", IsRequired = true, IsKey = false)]
[StringValidator(InvalidCharacters = " ~!@#$%^&*()[]{}/;'\"|", MaxLength = 60)]
public string User
{
get{ return (string)base[MyCustomSec._user]; }
set { base[MyCustomSec._user] = value; }
}

[ConfigurationProperty("default", DefaultValue = "false", IsRequired = true, IsKey = false)]
public string Default
{
get{ return (string)base[MyCustomSec._default]; }
set{ base[MyCustomSec._default] = value; }
}
protected override ConfigurationPropertyCollection Properties
{
get{ return MyCustomSec._properties; }
}
//protected override ConfigurationElementProperty ElementProperty
//{
// get{ return MyCustomSec.s_elemProperty; }
//}
}
}
re: Configuration Model in .Net 2.0 kmjacky 2006-03-03 01:48  
namespace ProjSite.Config
{
public sealed class MyCustomSectionGrp : ConfigurationSection
{
private Configuration m_cfg;

public void Save()
{
this.SectionInformation.ForceSave = true;
m_cfg.Save(ConfigurationSaveMode.Full);
}
private const string CS_SECTION = "myCustomGroup";
private static MyCustomSectionGrp m_current;
public static MyCustomSectionGrp Current
{
get
{
if (m_current == null)
{
Configuration cfg;
System.Web.HttpContext ctx = System.Web.HttpContext.Current;
if (ctx == null)
cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
else
cfg = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(
ctx.Request.ApplicationPath);
m_current = (MyCustomSectionGrp)cfg.Sections[CS_SECTION];
m_current.m_cfg = cfg;
}

return m_current;
}
}

static MyCustomSectionGrp()
{
propCustomSections = new ConfigurationProperty("CustomSections", typeof(MyCustomSecColletions),
null, ConfigurationPropertyOptions.None);
properties = new ConfigurationPropertyCollection();
properties.Add(propCustomSections);
}

[ConfigurationProperty("CustomSections")]
public MyCustomSecColletions customSections
{
get { return (MyCustomSecColletions)base[propCustomSections]; }
}
protected override ConfigurationPropertyCollection Properties
{
get
{
return MyCustomSectionGrp.properties;
}
}

private static readonly ConfigurationProperty propCustomSections;
private static ConfigurationPropertyCollection properties;
}
re: Configuration Model in .Net 2.0 kmjacky 2006-03-03 01:47  
你好,我按照你给的例子,自己改了一下,在ASP.net PAGE中修改了CustomSection的default属性, 但save 的时候报错,能帮我看一下这个代码吗?
error:
An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll
我设断点看了一下在
protected override ConfigurationPropertyCollection Properties
{
get{ return MyCustomSecColletions._properties; }
}
一直是死循环,不是太明白,谢谢了。 我的eMAIL:kmjacky@vip.sina.com

以下是web.config的片断:
----------------------------------------------------
<configSections>
<section name="myCustomGroup" restartOnExternalChanges="false" type="ProjSite.Config.MyCustomSectionGrp, App_Code" />
</configSections>
<myCustomGroup configSource="custom.config"></myCustomGroup>
---------------------------------------------------------
custom.config如下:
<myCustomGroup>
<CustomSections>
<CustomSection id="1" corp="C#Babcock" user="TL1\Administrator" default="false" />
<CustomSection id="2" corp="C#Babcock" user="TL1\jacky" default="false" />
<CustomSection id="3" corp="L#Babcock 1 name" user="TL1\Administrator"
default="true" />
<CustomSection id="4" corp="L#Babcock2" user="TL1\Administrator" default="false" />
<CustomSection id="5" corp="L#Babcock3" user="TL1\Administrator" default="false" />
<CustomSection id="6" corp="L#Babcock4" user="TL1\Administrator" default="false" />
<CustomSection id="7" corp="L#Babcock5" user="TL1\Administrator" default="false" />
<CustomSection id="8" corp="L#Babcock 1 name" user="TL1\jacky" default="true" />
<CustomSection id="9" corp="L#Babcock2" user="TL1\jacky" default="false" />
<CustomSection id="10" corp="L#Babcock3" user="TL1\jacky" default="false" />
<CustomSection id="11" corp="L#Babcock4" user="TL1\jacky" default="false" />
<CustomSection id="12" corp="L#Babcock5" user="TL1\jacky" default="false" />
</CustomSections>
</myCustomGroup>
re: Configuration Model in .Net 2.0 bryanzk 2006-01-11 14:45  
你好,我有个关于配置文件的问题,一句两句说不清,能帮我一下吗?
我的email:bryanzk@vip.sina.com
msn:bryanzk@hotmail.com
re: 八皇后问题 yskin 2005-10-26 09:04  
超级精简之八皇后程序
#include <stdio.h>
#define q(o) a[j]o[j+i+7]o[j-i+31]
int a[39];
void main(int i,int j)
{
for(j=9;--j;i>8?printf("%10d ",a[j]):q(|a)||(q(=a)=i,main(i+1,j),q(=a)=0));
}

八皇后不能在同一行,由鸽笼原理,8×8的格子最多只能有8个皇后。

还有,递归是简单的,看看高中的数学归纳法,可以解决很多别的方法解决不了的问题。

还有,我不知道什么叫“递归的不可控”,即使把程序改成非递归的,运行时间是大致相同的。而且这个程序之复杂,不像N的阶乘那样易于改成递推法。
最快的排序:快速排序用的不也是递归么?

递归的缺点在于函数调用用掉的时间过多,呵呵:)

用穷举法好像时间是稳定了,呵呵,稳定在一个很高的值上:)

tku.penny@msa.hinet.net
re: ReSharper 2.0 Preview Software gaojie 2005-10-12 19:29  
Tools | Options | Text Editor | C# | General | Statement completion

果然有用
Both of your invitations have been sent out...
Sorry, forget to tell you my email is luckyjason*gmail.com (change * to @)

I need yahoo 360 invitation, thanks a lot.
共6页: 1 2 3 4 5 6 下一页