C#索引指示器的应用
2006-09-18 13:39
246 查看
//c sharp 索引指示器的应用
using System;
class IndexExample
{
string Message;
public static void Main()
{
IndexExample obj=new IndexExample("Welcome");
for(int i=0;i<obj.Length;i++)
{
Console.WriteLine(obj[i]);
}
obj[obj.Length-1]="e to c#";
Console.WriteLine(obj.Message);
}
public IndexExample(string s)
{
Message=s;
}
public string this[int i]
{
get
{
if(i>=0 && i<Message.Length)
{
return Message.Substring(i,1);
}
else
{
return "";
}
}
set
{
if(i>=0 && i<Message.Length)
{
Message=Message.Substring(0,i)+value+Message.Substring(i+1);
}
}
}
public int Length
{
get
{
if(Message!=null)
{
return Message.Length;
}
else
return 0;
}
}
}
using System;
class IndexExample
{
string Message;
public static void Main()
{
IndexExample obj=new IndexExample("Welcome");
for(int i=0;i<obj.Length;i++)
{
Console.WriteLine(obj[i]);
}
obj[obj.Length-1]="e to c#";
Console.WriteLine(obj.Message);
}
public IndexExample(string s)
{
Message=s;
}
public string this[int i]
{
get
{
if(i>=0 && i<Message.Length)
{
return Message.Substring(i,1);
}
else
{
return "";
}
}
set
{
if(i>=0 && i<Message.Length)
{
Message=Message.Substring(0,i)+value+Message.Substring(i+1);
}
}
}
public int Length
{
get
{
if(Message!=null)
{
return Message.Length;
}
else
return 0;
}
}
}
相关文章推荐
- C#的事件和索引指示器
- 索引指示器的应用
- c sharp 索引指示器的应用
- C# lambda表达式应用如何找出元素在list中的索引
- C#学习之属性和索引指示器
- C#索引的应用 -c#的特殊性
- C#笔记----------------------------索引指示器
- C# 域 属性 索引指示器 命名空间 方法
- C# 接口 索引 属性 实质及应用 (收集)
- 索引指示器的应用
- 初步学习“C#索引指示器”
- 创建C#索引指示器
- C#中的索引指示器
- //蛙蛙推荐:演示索引指示器的用法(C#)
- C#关于域、属性、事件、索引指示器介绍
- C# 中实现索引指示器
- 创建C#索引指示器
- 插件式程序开发及其应用(C#) - 2(完成)
- Visual Studio 2005入门 之 索引指示器[视频]
- CORBA回调函数在C#项目环境中的应用