【C#课堂练习】索引器的声明和访问
本文最后更新于 1528 天前,其中的信息可能已经有所发展或是发生改变。

Program.cs
[sourcecode language=”c”]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
collclass collcalss = new collclass();
collcalss[3] ="傻子" ;
collcalss[4] ="傻子2" ;
for (int i = 0; i < collcalss.Length; i++)
{
Console.Write("{0} ", collcalss[i]);
}
Console.ReadKey();
}
}
class collclass
{
private string[] temp = new string[5] { "笨猪1", "笨猪2", "笨猪3", "笨猪4", "笨猪5" };
public int Length{
get { return temp.Length; }
}

public string this[int index]{
get{return temp[index];}
set{temp[index] = value;}
}
}
}
[/sourcecode]
效果图:

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇