返回   cpper编程论坛 > Blog
注册账号 论坛帮助 会员列表 日历事件 搜索 今日新帖 标记版面已读

旧

C# events VS delegates

发表于 2006-11-17 02:09 PM 作者: cat
C# events and delegates look asame at first glance. They both support operator +=, operator -=, invoking like a method, etc. However there should be some difference.

I searched it on the web and got this article:
http://blog.monstuff.com/archives/000040.html
And I summarize the major difference here:
1. events can be declared as a part of interface, while a delegate field can’t.
2. events have to be invoked within the class that declares it, while delegates...
cat
高级会员
发表在 未分类
评论 0 cat 当前离线
旧

.net 匿名delegate 可以修改的局部变量

发表于 2006-11-17 02:08 AM 作者: cat
代码:
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication5
{
    class Program
    {
        public delegate string F(int i);
        static void Main(string[] args)
        {
            F f = null;
            f = NewMethod(f);
            f(20);
            Console.ReadLine();
        }

        private static F NewMethod(F f)
...
cat
高级会员
发表在 未分类
评论 0 cat 当前离线
旧

做个简单的黑白棋(2)

发表于 2006-02-04 05:54 AM 作者: cat
上次主要的都有了,这次弄个简单的GUI就是了。

这里用一个简单的办法来做棋盘:Button数组。为了简单起见,我要在每个Button上增加一些功能,所以自定义了一个Button类,实现如下:

代码:
public class JMyButton extends JButton {
    private static final long serialVersionUID = -5948631467254568191L;

    public JMyButton(int x, int y) {
        this.x = x;
        this.y = y;

        if (!inited) {
             try {
                 black = new ImageIcon(ImageIO.read(new File("black.jpg")));
...
cat
高级会员
发表在 未分类
评论 0 cat 当前离线
旧

做个简单的黑白棋(1)

发表于 2006-02-02 10:31 AM 作者: cat
非常简单。这回弄点核心的类,下回弄UI. 就这破东西能应付我们大学一门课了.

首先做个Board类,我的这个类似乎肥了点,不管这么多了,实现了吃子(翻转)、历史纪录(Undo, Redo)以及取得一些盘面信息等功能。

给个接口(java):
代码:
package myothello;
public class Board {
    public Board();
    public int getBlackScore();
    public int getWhiteScore();
    public int getScore(int color);
    public int getStonesOnBoard();
    public int getCurrentColor();
    public int getCurrentStep();
    public boolean
...
cat
高级会员
发表在 未分类
评论 0 cat 当前离线
旧

Stored Procedure

发表于 2006-01-28 12:22 PM 作者: cat
最近学习中,记录一下:

优点:

1. 老声长谈的问题了:防止SQL注入。但这在通过标准的途径调用存储过程时不会发生,安全性提高很多。

2. 逻辑清晰,不需要写显示的SQL语句了,而只是调用函数的感觉,逻辑更清晰。

3. 效率考量,存储过程的执行计划(execution plan)很少需要更新,一次编译优化可以n次执行,效率较高。而直接的SQL语句动态执行,虽然也有caching优化,但一般来说还是比不上stored...
cat
高级会员
发表在 未分类
评论 1 cat 当前离线

所有时间均为格林尼治时间 +9。现在的时间是 02:04 PM


Powered by vBulletin® 版本 3.7.0
版权所有 ©2000 - 2008,Jelsoft Enterprises Ltd.
(C) Copy Right All Right Reserved 2001 - 2007

Search Engine Friendly URLs by vBSEO 3.1.0