首页
新闻
博问
会员
知识库
专题
.NET技术
Web前端
软件设计
手机开发
软件工程
程序人生
项目管理
数据库
最新文章
您的位置:
知识库
»
程序人生
回忆孔先生
作者:
梁逸晨
来源:
博客园
发布时间: 2008-12-25 23:34 阅读: 1488 次 推荐: 0
原文链接
[收藏]
摘要:
由鲁迅笔下的孔乙己这一人物展开的对程序员的描绘
[1]
1.人物刻画
[2] 2.敲击代码
[3]
3.结尾
using
System;
using
System.Data;
using
System.Data.Common;
namespace
kongyiji
{
interface
IHui
{
void
Print();
void
Print(
int
step);
}
/**/
///
///
抽象基类,实现通用的草字头输出
///
abstract
class
AHui: IHui
{
IHui i;
private
IDbCommand comm;
private
IDbConnection conn;
private
DbProviderFactory _dbFac;
private
IDbDataParameter pram;
public
AHui(DbProviderFactory DbFac)
{
Console.WriteLine(
"
艹
"
);
_dbFac
=
DbFac;
}
public
abstract
void
Print();
protected
void
SaveSwitch(
string
hui_type)
{
conn
=
_dbFac.CreateConnection();
conn.ConnectionString
=
@"
Data Source=localhost;Initial Catalog=local_db;Persist Security Info=True;User ID=sa;Password=123456789
"
;
comm
=
conn.CreateCommand();
comm.CommandText
=
"
INSERT INTO LOG(hui_type) VALUES(@hui_type);
"
;
pram
=
comm.CreateParameter();
pram.DbType
=
DbType.String;
pram.ParameterName
=
"
@hui_type
"
;
pram.Value
=
hui_type;
//
conn.Open();
//
comm.ExecuteNonQuery();
//
conn.Close();
}
public
void
Print(
int
step)
{
i
=
HuiFactory.Hui(_dbFac,step);
i.Print();
}
}
/**/
///
///
回字写法
///
class
SelectHui: AHui
{
string
_hui;
public
SelectHui(
string
select_hui, DbProviderFactory DbFac)
:
base
(DbFac)
{
_hui
=
select_hui;
}
public
override
void
Print()
{
Console.WriteLine(_hui);
SaveSwitch(_hui);
}
}
class
HuiFactory
{
public
static
IHui Hui(DbProviderFactory DbFac,
int
step)
{
IHui temp
=
null
;
switch
(step)
{
case
1
:
temp
=
new
SelectHui(
"
回
"
, DbFac);
break
;
case
2
:
temp
=
new
SelectHui(
"
囘
"
, DbFac);
break
;
case
3
:
temp
=
new
SelectHui(
"
囬
"
, DbFac);
break
;
case
4
:
temp
=
new
SelectHui(
"
廻
"
, DbFac);
break
;
default
:
temp
=
new
SelectHui(
"
廻
"
, DbFac);
break
;
}
return
temp;
}
}
class
Program
{
static
void
Main(
string
[] args)
{
DbProviderFactory fac
=
DbProviderFactories.GetFactory(
"
System.Data.SqlClient
"
);
IHui i
=
HuiFactory.Hui(fac,
4
);
i.Print();
i.Print(
2
);
}
}
}
后退<<上一页
继续>>下一页
[第1页]
[第2页]
[第3页]
0
0
请先
登录
提交中...
标签:
人生经验
«
上一篇:
程序员之江湖感想
»
下一篇:
新工作的教训
推荐链接
程序员问答平台,解决您的技术难题
程序人生热门文章
从P1到P7——我在淘宝这7年
程序猿媳妇儿注意事项
可是姑娘,你为什么要编程呢?
技术的正宗与野路子
程序员,如何从平庸走向理想?
程序人生最新文章
如何高效的学习技术
程序员的重复劳动陷阱
如何阅读技术书籍
你解决的问题比你编写的代码更重要!
程序员,为什么千万不要重写代码?
最新新闻
史诗时刻!AlphaGo神之一手突现,谷歌AI颠覆科研极限?
张朝阳、傅盛等人激辩中美AI竞争,张亚勤:未来5年中国最大优势是人才
外媒称英伟达计划在上海建研究中心,“将聚焦中国客户定制化需求”
翁荔最新万字长文:Why We Think
黄仁勋最新表态:将调整对华芯片出口
热门新闻
R2来之前,DeepSeek又放了个烟雾弹
小米自研手机芯片来了!雷军官宣5月下旬发布,十年“造芯”重大突破
雷军最新内部演讲:一场事故给小米带来巨大质疑,很多活动取消,小米不再是行业新人
DeepSeek首曝V3降成本秘诀!软硬协同突破Scaling天花板
深海海底99.999%仍未探索