How to check!

How to check whether a number is prime or not however it is arranged.
e.g:- 113 , no matter how you arrange it, it will be prime, 131, 311, how to implement it in C# ??