You have 3 options:
1) Get default value
dt = datetime??DateTime.Now;
it will assign DateTime.Now
(or any other value which you want) if datetime
is null
2) Check if datetime contains value and if not return empty string
if(!datetime.HasValue) return "";
dt = datetime.Value;
3) Change signature of method to
public string ConvertToPersianToShow(DateTime datetime)
It's all because DateTime?
means it's nullable DateTime
so before assigning it to DateTime
you need to check if it contains value and only then assign.