Answers for "string reference not set to an instance of a string."

2

string reference not set to an instance of a string.

DateTime dt2 = new DateTime();


    dt = DateTime.ParseExact(YearOfRelease, "dd/MM/yyyy hh:mm:ss", null);

    Year = dt.Year.ToString();


    dt2 = DateTime.ParseExact(RunTime, "dd/MM/yyyy hh:mm:ss", null);
    string hour = dt2.Hour.ToString();
    string min = dt2.Minute.ToString();

    Time = hour + ":" + min;
Posted by: Guest on June-07-2021
0

string reference not set to an instance of a string.

The first parameter of DateTime.ParseExact is a string parameter named 's'.

Therefore, it looks like YearOfRelease or RunTime is null in your program. Make sure those are set before you call DateTime.ParseExact.
Posted by: Guest on June-17-2021

Code answers related to "string reference not set to an instance of a string."

Browse Popular Code Answers by Language