I created a DatePicker in Xamarin, and I have a problem with it. I tried to make a code for calculating a person's age by adding the born year, month and day. However the code after debugging stopped at the point when I converted the number of years into string, giving me the error: "A Android.Content.Res.Resources+NotFoundException was thrown. String resource ID #0x2"
Xamarin code:
base.OnCreate (bundle);
SetContentView (Resource.Layout.AddDataLayout);
Button regbutton = FindViewById<Button> (Resource.Id.regButton);
DatePicker date = FindViewById<DatePicker> (Resource.Id.datePicker);
//regbutton.Enabled = false;
regbutton.Click += delegate
{
DateTime zeroTime = new DateTime(1, 1, 1);
DateTime BornDate = date.DateTime;
DateTime sToday = DateTime.Today;
TimeSpan span = sToday - BornDate;
int years = (zeroTime + span).Year - 1;
string a = Convert.ToString(years);
Toast.MakeText(this,a , ToastLength.Long).Show();
this.Finish();
};