// C# code for kth smallest element
// in an array
using System;
public class GFG {
// Function to return k'th smallest
// element in a given array
public static int kthSmallest(int []arr,
int k)
{
// Sort the given array
Array.Sort(arr);
// Return k'th element in
// the sorted array
return arr[k-1];
}
// driver program
public static void Main()
int []arr = new int[]{12, 3, 5,
7, 19};
int k = 2;
Console.Write( "K'th smallest element"
+ " is "+ kthSmallest(arr, k) );
// This code is contributed by nitin mittal.
/*Output:
K'th smallest element is 5 */