仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 615|回复: 8
打印 上一主题 下一主题

[学习教程] ASP.NET教程之C#进修条记之四(Attribute, Reflectio...

[复制链接]
简单生活 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 22:50:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
我以前很喜欢Serv-U,自从它用Java重写之后我就再也没用过,实在是太慢了,我宁可用IIS搭建FTP,虽然IIS搭建FTP在权限管理上很不灵活。Atributes:
//canaddmetadatainprogram,Itstorewiththeprogram
//usingILDasmtocheckatributes

//usage
[CodeReviewAttribute("08/08/2005","AllanZhang",
Comment="ThatisaAttributetest")]
classEmployee{}

//definetargetandatr
[AttributeUsage(AttributeTargets.Class|
AttributeTargets.Constructor|
AttributeTargets.Interface|
AttributeTargets.Method|
AttributeTargets.Field|
AttributeTargets.Property,
AllowMultiple=true)]
classCodeReviewAtrribute:System.Attribute
{
privatestringreviewDate;
privatestringreviewerName;
privatestringreviewComments;
...
}

Reflections://lookthemetadatainprogram,discory,latebinding

//DisplayattributeinCode
System.Reflection.MemberInfoinf=typeof(Employee);
object[]atributes=inf.GetCustomAttributes(false);
foreach(objectattributeinattributes)
{
CodeReviewAttributeattr=(CodeReviewAttribute)attribute;
Console.WriteLine("Thisiscodewasreviewedon{0}by{1}
Comments{2}",
attr.date,
attr.name,
attr.comment)
}

//Discovery
Assemblyasm=Assembly.Load("Mscorlib.dll");
Type[]types=asm.GetTypes();
foreach(Typetypeintypes)
{
Console.WriteLine("Typeis{0},type);
Console.WriteLine("
{0}typesfound."types.Length);
}

//LateBinding
TypemathType=Type.GetType("System.Math");
objectobj=Activator.CreaterInstance(mathType);

Type[]parameterTypes=newType[2];
parameterTypes[0]=Type.GetType("System.Double");
parameterTypes[1]=Type.GetType("System.Double");
MethodInfopowInfo=mathType.GetMethod("Pow",parameterTypes);

object[]parameters=newobject[2];
parameters[0]=5;
parameters[1]=3;
objectreturnValue=powInfo.Invoke(obj,parameters);
Console.WriteLine("5tothe3rdpoweris{0},returnValue);

Thread:
//CreateImplicitThreads

usingSystem.Threading
ThreadthreadOne=newThread(newThreadStart(Countup));
ThreadthreadTwo=newThread(newThreadStart(Countup));
threadOne.Name="ThreadOne";
threadTwo.Name="Threadtwo";
threadOne.Start();
threadTwo.Start();

//Joining&killingThreads
//jointwothreadsincurrentthrea
threadOne.start();
threadTwo.Start();
threadOne.Join();
threadTwo.Join();
//thiswillprint,aftertwoabovetwothreadsends
Console.WriteLine("Theotherthreadsdone");
//sleep(millisenconds)
threadOne.sleep(1);
threadOne.Abort();

Synchronization:
//1.noconflictbetweenthreads
interlocked.Increment(refsynchValue);
//2.lockmethod,thiswillblockotherthreadwhenitenterintoit
lock(this)
{
inttemp=synchValue;
temp++;
Thread.Sleep(2);
synchValue=temp;
synchValue=temp;
Console.WriteLine("{0}Countup:{1}",
Thread.CurrentThread.Name,
synchValue);
}

Java欺骗了我们那么多年,如今的多核时代,我认为它气数已尽!
山那边是海 该用户已被删除
沙发
发表于 2015-1-18 16:28:25 | 只看该作者
使用普通的文本编辑器编写,如记事本就可以完成。由脚本在服务器上而不是客户端运行,ASP所使用的脚本语言都在服务端上运行,用户端的浏览器不需要提供任何别的支持,这样大提高了用户与服务器之间的交互的速度。
不帅 该用户已被删除
板凳
发表于 2015-1-22 12:37:21 | 只看该作者
ASP在执行的时候,是由IIS调用程序引擎,解释执行嵌在HTML中的ASP代码,最终将结果和原来的HTML一同送往客户端。
谁可相欹 该用户已被删除
地板
发表于 2015-1-31 06:41:47 | 只看该作者
由于JSP/Servlet都是基于Java的,所以它们也有Java语言的最大优点——平台无关性,也就是所谓的“一次编写,随处运行(WORA–WriteOnce,RunAnywhere)”。除了这个优点,JSP/Servlet的效率以及安全性也是相当惊人的。
海妖 该用户已被删除
5#
发表于 2015-2-6 17:55:48 | 只看该作者
能产生和执行动态、交互式、高效率的站占服务器的应用程序。运用ASP可将VBscript、javascript等脚本语言嵌入到HTML中,便可快速完成网站的应用程序,无需编译,可在服务器端直接执行。容易编写。
变相怪杰 该用户已被删除
6#
发表于 2015-2-17 22:08:46 | 只看该作者
逐步缩小出错代码段的范围,最终确定错误代码的位置。
灵魂腐蚀 该用户已被删除
7#
发表于 2015-3-5 23:12:04 | 只看该作者
ASP在执行的时候,是由IIS调用程序引擎,解释执行嵌在HTML中的ASP代码,最终将结果和原来的HTML一同送往客户端。
兰色精灵 该用户已被删除
8#
发表于 2015-3-12 16:35:40 | 只看该作者
现在的ASP.net分为两个版本:1.1和2.0Asp.net1.1用VS2003(visualstudio2003)编程。Asp.net2.0用VS2005(visualstudio2005)编程。现在一般开发用的是VS2003。
因胸联盟 该用户已被删除
9#
发表于 2015-3-20 00:11:59 | 只看该作者
现在主流的网站开发语言无外乎asp、php、asp.net、jsp等。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-6-24 20:06

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表