by Piotrosz
6. March 2009
Odpowiedniki funkcji
Left oraz
Right z Visual Basica czy SQL:
class Program
{
public static string Left(string Value, int Length)
{
return (Value.Length > Length) ? Value.Substring(0, Length) : Value;
}
public static string Right(string Value, int Length)
{
return (Value.Length > Length) ? Value.Substring(Value.Length - Length, Length) : Value;
}
static void Main(string[] args)
{
for (int i = 0; i < 15; i++)
Console.WriteLine(Left("1234567890", i));
Console.WriteLine();
for (int i = 0; i < 15; i++)
Console.WriteLine(Right("1234567890", i));
// Wynik działania:
//
//1
//12
//123
//1234
//12345
//123456
//1234567
//12345678
//123456789
//1234567890
//1234567890
//1234567890
//1234567890
//1234567890
//
//
//0
//90
//890
//7890
//67890
//567890
//4567890
//34567890
//234567890
//1234567890
//1234567890
//1234567890
//1234567890
//1234567890
}
}