Lire le dernier élément d'un ArrayList dans C# et VB.Net
Comment afficher le dernier élément d'un arraylist ?
VB.Net
01.
Protected
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
Handles
Me
.Load
02.
Dim
arrList
As
ArrayList =
New
ArrayList()
03.
arrList.Add(9889)
04.
arrList.Add(DateTime.Now)
05.
arrList.Add(
"Floppy.cat"
)
06.
If
arrList.Count > 0
Then
07.
Response.Write(
"Last Item : "
& arrList(arrList.Count - 1))
08.
End
If
09.
End
Sub
C#
01.
protected
void
Page_Load(
object
sender, EventArgs e)
02.
{
03.
ArrayList arrList =
new
ArrayList();
04.
arrList.Add(8998);
05.
arrList.Add(DateTime.Now);
06.
arrList.Add(
"Open-Game-Room.Net"
);
07.
if
(arrList.Count > 0)
08.
{
09.
Response.Write(
"Last Item : "
+ arrList[arrList.Count - 1]);
10.
}
11.
}