Fundamentals of Computer Programming with C#: I need help with the solution in Chapter 1 problem 10

Write a program that reads your age from the console and prints your age after 10 years.

What have you tried so far?

Hi,

I just noticed my description said problem 10 but this is for problem 11 in Chapter 1. I researched DateTime.AddYears(Int32) Method (System) | Microsoft Docs, but was not able to determine or find any examples of adding an int value to DateTime. It only returns the date format. I have provided the code I most recently tried, but have tried a variety of formats and still cannot get this to work properly using System.DateTime.Addyears()

        Console.WriteLine("Please, enter your age");
        int age = int.Parse(Console.ReadLine());

        DateTime myNewAge = DateTime.Now.AddYears(10);
        
        Console.WriteLine(myNewAge + age);

DateTime class is quite complex for introductory problems, I suggest a simpler solution - for example the input can be your age as a number, and then convert this to int, and print it with 10 added.

Thanks. I was able to get your solution to work.

Thanks …this works

Console.WriteLine(“Please, enter your age”);
int age = int.Parse(Console.ReadLine());

        Console.WriteLine("Your future age is: " + (age + 10) );