What are you trying to accomplish? What is your intended goal for this code? I had to add a ';' to the end of input 1 and define res as a bool.
Using the below code, I received a console output of '1'.
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string input1 = "12/12/1991";
DateTime dt;
bool res = DateTime.TryParseExact(input1, "MM/dd/yyyy", null, System.Globalization.DateTimeStyles.None, out dt);
if (res == true)
{
int year = DateTime.Now.Year - dt.Year;
int month = DateTime.Now.Month - dt.Month;
if (month < 0)
{
year = year - 1;
month = month + 12;
}
if (year > 18)
{
Console.WriteLine("1");
}
else
{
Console.WriteLine("-1");
}
}
}
}
}