I am starting to learn ASP.NET with C# and I am trying to create the Data Access Layer and Business Logic Layers for my .aspx page.
In my DAL (.xsd) I have a Table called Parts that contains field "Weight" that is a System.Double
In my BLL I am making a function that eventually Add Parts to my Parts table. The first thing I want to do is just check that values that my AddParts function is getting are null, and if so then it will pass null to the DAL INSERT function. Needlessly to say I am having issues. Here is some of my code from the BLL in the AddParts function:
The intellisense has highlighted the red part above as an issue. When I hover over it, it says
"parameter weight? double
Error: Cannot implicitly covert 'double?' to 'double'. An explicit casting exists (are you missing a cast?)"
I am not really sure what is going on here. Maybe it has to do with the '?' after the double? in the function declaration, or maybe not. Does anyone know what's going on?
Do I even need the '?' If not, what is it for? I just found this type of code on the site I am using to learn ASP with C# asp.net/learn/ I haven't quite figured out why they use the '?' after some fields and not others.
Can anyone help me with understanding these two things and why I am getting this error...
Thanks to any help.
In my DAL (.xsd) I have a Table called Parts that contains field "Weight" that is a System.Double
In my BLL I am making a function that eventually Add Parts to my Parts table. The first thing I want to do is just check that values that my AddParts function is getting are null, and if so then it will pass null to the DAL INSERT function. Needlessly to say I am having issues. Here is some of my code from the BLL in the AddParts function:
Code:
[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Insert, true)]
public bool AddPart(string partNum, string manufact, string model, string description, string upc, double? weight, double? height,
double? width, double? depth, int? trackSerial, string pictureURL)
{
...
...
if (weight == null)
part.SetWeightNull();
else
part.Weight = [red]weight;[/red]
...
}
"parameter weight? double
Error: Cannot implicitly covert 'double?' to 'double'. An explicit casting exists (are you missing a cast?)"
I am not really sure what is going on here. Maybe it has to do with the '?' after the double? in the function declaration, or maybe not. Does anyone know what's going on?
Do I even need the '?' If not, what is it for? I just found this type of code on the site I am using to learn ASP with C# asp.net/learn/ I haven't quite figured out why they use the '?' after some fields and not others.
Can anyone help me with understanding these two things and why I am getting this error...
Thanks to any help.