Based on your code I think it's safe to assume that
s.d_date_birth
is a
DateTime?
value. This is a
Nullable<DateTime>
which doesn't have a
ToString()
method which accepts a format.
You almost had it right in your attempted code, you could try doing:
s_date_birth = s.d_date_birth?.ToString("dd/MM/yyyy") ?? string.Empty,
That will loosely compile to:
s_date_birth = s.d_date_birth.HasValue ? s.d_date_birth.Value.ToString("dd/MM/yyyy") : string.Empty,
You have to access the
Value
property of a nullable type to get the underlying value.