摘要:
c#与java的比较(转二)
5. 指代(delegate)
指代这个玩意很特别,它有点象指针,但又不完全是,不过大家还是可以把它理解为一种类型安全的、面向对象的指针。(什么是类型安全和面向对象就不用讲了吧?)顺便提一句,有很多书上把delegate翻译成代理,我觉得这样翻不够确切,翻译成“指代”更恰当些,道理上吻合,并且还符合它的本来意思——微软本来就是用delegat......
摘要:
在一个namespace中,我们也可以用一个别名指代现有的namespace或是一些其他类型数据。
别名的使用格式如下:
using 别名 = 一个已经存在的类型;
例如:using soholife = system;
下面我们通过几个例子来加深一下理解:
namespace n1.n2
{
class a {}
}
namespace n3......
正则表达式应用范例(转)
the following example shows the use of regular expresssions in c#.this program has basic validation scripts for validation easily useable in all programs.
/*
<howtocompile>
csc /r:system.text.regularexpressions.dll,system.dll validation.cs
</howtocomplie>
*/
using system.text.regularexpressions;
using system;
class validation
{
public static void main()
{
string strtotest;
validation objvalidate=new validation();
console.write("enter a string to test for alphabets:");
strtotest=console.readline();
if(objvalidate.isalpha(strtotest))
{
console.writeline("{0} is valid alpha string",strtotest);
}
else
{
console.writeline("{0} is not a valid alpha string",strtotest);
}
}
// function to test for positive integers.
public bool isnaturalnumber(string strnumber)
{
regex objnotnaturalpattern=new regex("[^0-...
下一页 摘要:
<展现 c#> 第一章 c#简介(rainbow 翻译)
出处:http://www.informit.com/matter/ser0000001/chapter1/ch01.shtml
正文:
展现 c#
第一章 c# 简介
欢迎您加入c#的世界! 这一章将把您引进c#的天地,并回答一些相关的问题,如:您为什么要使用c#,c++和c#的主要有什么不同......