Validate method written in C# language