What is the error in below code? Why can't I convert it to int | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

What is the error in below code? Why can't I convert it to int

int age=0; age=Convert.ToInt32(DateTime.Now-this.dateOfBirth);

4th Apr 2020, 3:42 PM
amith
2 Answers
0
public int CalculateAge() { int age=0; age = Convert.ToInt32(DateTime.Now-this.dateOfBirth); return age; } this.dateOfBirth is a parameter passed to Constructor
4th Apr 2020, 4:32 PM
amith
- 1
hey amith if you don't mind showing the piece of code at large that might help clear somethings
4th Apr 2020, 4:21 PM
✳AsterisK✳
✳AsterisK✳ - avatar