kwh3856
asked on
Cannot implicitly convert type 'int?' to 'int'. An explicit conversion exists (are you missing a cast?)
I am not sure I understand this error message. If two variable are already defined as integer why am I getting this error message. I am not sure what it means. Any help is greatly appreciated.
Here is my code where I get it.
Here is my code where I get it.
// Global Variables Class
internal static class MyGlobalVars
{
public static int docnpi;
public static Guid initGuid;
}
................down in the middle of my code I have................................
myMPI.NPI = Convert.ToInt32(patient.d.NPI);
MyGlobalVars.docnpi = myMPI.NPI;--------squiggly under the myMPI.NPI
you might want to do this
if(patient.d.NPI.HasValue)
myMPI.NPI = patient.d.NPI.Value;
if(patient.d.NPI.HasValue)
myMPI.NPI = patient.d.NPI.Value;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Will probably work if you add (int) in front of it (including brackets).
Ah, forget my comment, I didn't read well. Naspinski has better eyes here ;)
a little cleaner:
MyGlobalVars.docnpi = myMPI.NPI.GetValueOrDefault();
ASKER
naspinski,
Thank you. Your code worked just by pasting it in. To each of you who chimed in, thank you. Naspinski seemed to have the best solution for what I needed at this time. Once again, thank you.
Thank you. Your code worked just by pasting it in. To each of you who chimed in, thank you. Naspinski seemed to have the best solution for what I needed at this time. Once again, thank you.
not sure that you need the conversion though