最近公司让我做Windows mobile的开发,窗体的背景画了一个图片,可是把控件拖到上面的时候,控件有背景色,就想问这个问题解决呀?如果自己写控件,现在还没有到那个火侯!
posted @ 2008-12-23 16:13 *海风* 阅读(97) 评论(4) 编辑
1
// 定义一个猫的类
2
function Cat(description) {
3
// 定义一个事件
4
this.description = description;
5
this.cry = null;
6
}
7
// 添加事件
8
Cat.prototype.AddHandler = function(handler) {
9
if (this.cry == null) {
10
this.cry = new Array();
11
this.cry[this.cry.length] = handler;
12
} else {
13
this.cry[this.cry.length] = handler;
14
}
15
}
16
// 定义猫叫的方法
17
Cat.prototype.OnCry = function() {
18
alert("Cat:miao miao
.");
19
for (var i = 0;i < this.cry.length; i++) {
20
this.cry[i](this);
21
}
22
}
23
// 定义一个老鼠类,老鼠对猫的叫感兴趣,所以就注册了cry事件
24
function Mouse() {
25
}
26
Mouse.prototype.Run = function(des) {
27
switch (des.description) {
28
case "laze" :
29
alert("操,你吓我是吧,你能追的上我吗,我就不跑!");
30
break;
31
case "smark" :
32
alert("我日,你来了呀,你NB,我走!");
33
break;
34
}
35
}
36
var c = new Cat('laze');
37
var c2 = new Cat('smark');
38
var m = new Mouse();
39
c.AddHandler(m.Run);
40
c2.AddHandler(m.Run);
41
// 先让懒猫先叫
42
c.OnCry();
43
// 再让NB的猫再叫
44
c2.OnCry();
// 定义一个猫的类2
function Cat(description) {3
// 定义一个事件4
this.description = description;5
this.cry = null;6
}7
// 添加事件8
Cat.prototype.AddHandler = function(handler) {9
if (this.cry == null) {10
this.cry = new Array();11
this.cry[this.cry.length] = handler;12
} else {13
this.cry[this.cry.length] = handler;14
}15
}16
// 定义猫叫的方法17
Cat.prototype.OnCry = function() {18
alert("Cat:miao miao
.");19
for (var i = 0;i < this.cry.length; i++) {20
this.cry[i](this);21
}22
}23
// 定义一个老鼠类,老鼠对猫的叫感兴趣,所以就注册了cry事件24
function Mouse() {25
}26
Mouse.prototype.Run = function(des) {27
switch (des.description) {28
case "laze" :29
alert("操,你吓我是吧,你能追的上我吗,我就不跑!");30
break;31
case "smark" :32
alert("我日,你来了呀,你NB,我走!");33
break;34
}35
}36
var c = new Cat('laze');37
var c2 = new Cat('smark');38
var m = new Mouse();39
c.AddHandler(m.Run);40
c2.AddHandler(m.Run);41
// 先让懒猫先叫42
c.OnCry();43
// 再让NB的猫再叫44
c2.OnCry();posted @ 2008-07-18 16:10 *海风* 阅读(186) 评论(0) 编辑
也许你是一个老实的人,没有谈过朋友,也许你是一个花花公子,追过很多女孩子,也被许多女孩子追过,总之你的一生就像是一个很长很长的字符串,每一个字符代表在你的人生中出现过的女孩子,到你快要离开人世的时候,你在回想,每个女孩你追过多少次呢,现在就帮你解答:
一:正则求解
static void Main(string[] args)
{
ArrayList list = new ArrayList();
Console.WriteLine("Please input a string");
string appearWord="";
string test = Console.ReadLine();
char[] c = test.ToCharArray();
foreach (char cc in c)
{
if(!list.Contains(cc.ToString()))
{
list.Add(cc.ToString());
}
}
list.Sort();
for(int i=0;i<list.Count;i++)
{
appearWord+=list[i].ToString();
}
Console.WriteLine("You input a string just:{0}", test);
Console.WriteLine("你刚输入的字符串中一共有{0},字符出现,它们是:{1}", list.Count, appearWord);
for (int j = 0; j < list.Count; j++)
{
Console.WriteLine("{0}出现的次数是:{1}", list[j].ToString(), returnAppareNum(test, list[j].ToString()));
}
Console.Read();
}
//一个字符或者字符串在另一个字符串出现的次数
static int returnAppareNum(string source, string patten)
{
MatchCollection mc = Regex.Matches(source, patten);
return mc.Count;
}二:递归求解
static void Main(string[] args)
{
string test = "ubaadfasd";
abc(test);
Console.Read();
}
public static void abc(string source)
{
string aaa = "";
if (source.Length > 0)
{
string a = source.Substring(0, 1);
Console.WriteLine("{0}出现{1}次",a,ab(source, a));
aaa=source.Replace(a, "");
abc(aaa);
}
}
public static int ab(string dd, string aad)
{
int num = 0;
char[] c = dd.ToCharArray();
for (int i = 0; i < c.Length; i++)
{
if (c[i].ToString().Equals((object)aad))
{
num += 1;
}
}
return num;
}posted @ 2008-05-07 13:23 *海风* 阅读(150) 评论(1) 编辑


