会员
周边
众包
新闻
博问
闪存
赞助商
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
跟进中...
Flowing...
博客园
首页
新随笔
联系
订阅
管理
Just For Fun
using
System;
using
System.Collections.Generic;
using
System.Text;
using
System.Collections;
namespace
TestFuns
{
class
Program
{
Functions
#region
Functions
/**/
///
<summary>
///
数列
///
</summary>
///
<param name="n"></param>
///
<returns></returns>
private
static
int
numlist(
int
n)
{
if
(n
<
2
)
return
1
;
else
return
numlist(n
-
1
)
+
numlist(n
-
2
);
}
/**/
///
<summary>
///
显示1-50随机数,各不相同
///
</summary>
private
static
void
InsertRandomArr()
{
int
tmpNum
=
0
;
ArrayList newarr
=
new
ArrayList();
Random rd
=
new
Random();
while
(newarr.Count
<
50
)
{
tmpNum
=
rd.Next(
0
,
51
);
if
(
!
newarr.Contains(tmpNum))
newarr.Add(tmpNum);
}
for
(
int
i
=
49
; i
>
0
; i
--
)
{
Console.Write(newarr[i].ToString()
+
"
"
);
}
}
#endregion
DelegateDemo
#region
DelegateDemo
public
class
ShowMsgInfo
{
public
delegate
string
msgOut(
string
str);
public
msgOut ShowMsg;
}
public
static
string
ShowHTML(
string
str)
{
return
string
.Format(
"
<B>{0}</B>
"
, str);
}
public
static
string
ShowTXT(
string
str)
{
return
str;
}
#endregion
static
void
Main(
string
[] args)
{
for
(
int
i
=
0
; i
<
10
; i
++
)
Console.WriteLine(numlist(i));
InsertRandomArr();
ShowMsgInfo sm
=
new
ShowMsgInfo();
sm.ShowMsg
=
new
ShowMsgInfo.msgOut(ShowHTML);
Console.WriteLine(sm.ShowMsg(
"
Test
"
));
sm.ShowMsg
=
new
ShowMsgInfo.msgOut(ShowTXT);
Console.WriteLine(sm.ShowMsg(
"
Test2
"
));
Console.Read();
}
}
}
posted @
2009-11-13 20:14
David Dong
阅读(
231
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
公告