Due to inertia, indexer is often used as an entry to feedback results by number.
But like where in SQL, we can actually do a lot.
Using System;
Using System. Collections. Generic;
Using System. text;
Namespace Leleapplication2
{
Class C
{
Float [] Temps = New Float [ 10 ] {
56.2f , 56.7f , 56.5f , 56.9f , 58.8f , 61.3f , 65.9f , 62.1f , 59.2f , 57.5f };
Public Float This [ Int Index]
{
Get { Return Temps [Index];}
Set {Temps [Index] = Value ;}
}
Public String This[StringIndex]
{
Get{ReturnIndex ;}
}
/// <Summary>
/// Offers features similar to federated PK
/// </Summary>
/// <Param name = "Index"> </param>
/// <Param name = "I"> </param>
/// <Returns> </returns>
Public String This [ String Index, Int I]
{
Get { Return Index + I ;}
}
/// <Summary>
/// It can be very similar to the WHERE clause in SQL statements.
/// </Summary>
/// <Param name = "Predicate"> </param>
/// <Returns> </returns>
Public Float This [Predicate < Float > Predicate]
{
Get
{
Float [] Matches = Array. findall < Float > (Temps, predicate );
# Region Output intermediate results
String [] Info = Array. convertall < Float , String > (
Matches,
Delegate ( Float F)
{
Return Convert. tostring (f );
}
);
Console. writeline ( String . Join ( " , " , Info ));
# Endregion
ReturnMatches [0];
}
}
/// <Summary>
/// It can be very similar to the effect of a group of where clauses in SQL statements.
/// </Summary>
/// <Param name = "predicates"> </param>
/// <Returns> </returns>
Public Float This [ Params Predicate < Float > [] Predicates]
{
Get
{
// For specific implementation, refer to the above example. Basically, it is similar to where for SQL writing.
// The specific implementation is omitted
Return - 1 ;
}
}
}
Class Program
{
Static Void Main ( String [] ARGs)
{
C = New C ();
Console. writeline (C [ 4 ]);
Console. writeline (C [ " Second " ]);
Console. writeline (C [ " Second " , 2 ]);
Console. writeline (
C [
Delegate ( Float F)
{
Return F > 62f;
}]);
}
}
}