- 博客(0)
- 资源 (7)
- 收藏
- 关注
As you can see,indexers behave much like a custom collection supporting the IEnumeratorand
As you can see,indexers behave much like a custom collection supporting the IEnumeratorand
IEnumerableinterfaces in that they provide access to a container’s subitems. The major difference
ofcourse is that rather than accessing the contents using the foreachconstruct, you are able to
manipulate the internal collection of sub-objects just like a standardarray.
Now for the big question: How do you configure the PeopleCollectionclass (or any class/
structure) to support this functionality? An indexer is represented as a slightly mangled C# property.
Inits simplest form, an indexer is created using the this[]syntax. Hereis the required update for
the PeopleCollectionclass:
2010-08-03
c#gaojichengxu
static void gettoken()
{
token.Remove(0, token.Length);
char c = prog[i];
while (c == ' '){
i++;
c=prog[i];
}
if (c == '+'|| c == '-' || c == '*' || c == '/')
{
token_t = DILIM;
token.Append(c);
++i;
}
else if (c > '0' && c < '9')
{
token_t = NUM;
while (c > '0'&& c < '9')
{
token.Append(c);
if (i >= prog.Length-1)
{
return;
}
else
{
c = prog[++i];
}
}
}
else
{
token_t = ERR;
}
}
static void arith(char op, ref float r, float h)
{
switch (op)
{
case '+':
r = r + h;
break;
case '-':
r = r - h;
break;
case '*':
r = r * h;
break;
case '/':
r = r / h;
break;
}
}
static void lev1(ref float r)
{
char op;
float h=0F;
gettoken();
lev2(ref r);
op = token[0];
while (op == '+' || op == '-')
{
gettoken();
lev2(ref h);
arith(op, ref r, h);
gettoken();
//gettoken();
// arith(op, ref r, h);
op = token[0];
}
}
static void lev2(ref float r)
{
char op;
float h;
String s = token.ToString();
r=float.Parse (s);
gettoken();
op = token[0];
while ((op == '*') ||( op == '/'))
{
gettoken();
s = token.ToString();
h=float.Parse (s);
arith(op, ref r, h);
gettoken();
op = token[0];
}
}
}
}
2010-08-02
c#gaojibiancheng
static void gettoken()
{
token.Remove(0, token.Length);
char c = prog[i];
while (c == ' '){
i++;
c=prog[i];
}
if (c == '+'|| c == '-' || c == '*' || c == '/')
{
token_t = DILIM;
token.Append(c);
++i;
}
else if (c > '0' && c '0'&& c = prog.Length-1)
{
return;
}
else
{
c = prog[++i];
}
}
}
else
{
token_t = ERR;
}
}
static void arith(char op, ref float r, float h)
{
switch (op)
{
case '+':
r = r + h;
break;
case '-':
r = r - h;
break;
case '*':
r = r * h;
break;
case '/':
r = r / h;
break;
}
}
static void lev1(ref float r)
{
char op;
float h=0F;
gettoken();
lev2(ref r);
op = token[0];
while (op == '+' || op == '-')
{
gettoken();
lev2(ref h);
arith(op, ref r, h);
gettoken();
//gettoken();
// arith(op, ref r, h);
op = token[0];
}
}
static void lev2(ref float r)
{
char op;
float h;
String s = token.ToString();
r=float.Parse (s);
gettoken();
op = token[0];
while ((op == '*') ||( op == '/'))
{
gettoken();
s = token.ToString();
h=float.Parse (s);
arith(op, ref r, h);
gettoken();
op = token[0];
}
}
}
}
2010-08-02
c#ftp://61.132.59.166/计算机类/shubulo/ProfessionalCsharp_4thE_CHN.rar
ftp://61.132.59.166/计算机类/shubulo/ProfessionalCsharp_4thE_CHN.rar
ftp://61.132.59.166/计算机类/shubulo/ProfessionalCsharp_4thE_CHN.rar
ftp://61.132.59.166/计算机类/shubulo/ProfessionalCsharp_4thE_CHN.rar
2010-07-30
c#高级编程英文版目录目录目录目录
Ⅰ部分 C# 语 言
第1章 .NET体系结构.... 3
1.1 C#与.NET的关系...... 3
1.2 公共语言运行库...... 3
1.3 详细介绍中间语言...... 6
1.3.1 面向对象和接口的支持..... 7
1.3.2 相异值类型和引用类型..... 8
1.3.3 强数据类型..... 8
1.3.4 通过异常方法处理错误..... 14
1.3.5 特性的使用..... 14
1.4 程序集...... 14
1.4.1 私有程序集..... 15
1.4.2 共享程序集..... 16
1.4.3 反射..... 16
1.5 .NET Framework类...... 16
1.6 命名空间...... 17
1.7 用C#创建.NET应用程序...... 18
1.7.1 创建ASP.NET应用程序..... 18
1.7.2 创建Windows窗体..... 20
1.7.3 Windows控件..... 20
1.7.4 Windows服务..... 20
1.8 C#在.NET企业体系结构中
的作用...... 20
1.9 小结...... 22
第2章 C#基础.... 23
2.1 引言...... 23
2.2 第一个C#程序...... 23
2010-07-29
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人