asp.net - VB Single line with null values -


I have the following code that I do not believe is working properly and I can not understand why. Slow number in the form of decimals? = If (nothing is before or second, there is nothing, _ nothing, _ Math.Ebus (if (first, 0D)) - Math.Ebus (if (second, 0D)) before or second , then nothing should be kept in total . , If there are values ​​in both, then both of them must be converted into positive values ​​and first - second should be calculated. First and second are both qualified decimal (decimals?). / P>

Expected Result:

  before = none = nothing = nothing:   

Actual results:

  first = nothing = nothing = 0d   

I do not understand if the statement is not going in the correct section and in the variable total Nothing is putting

if () operator is typed strongly , But the compiler has been estimated that kind of result based on input

In this case, it can not guess the type from the first option ( nothing ), because the self does not have any type, and not the opposite of C # null , anything can not be lower than the value type (it will be important in an instant). Therefore the compiler should see the second option: Math.Abs ​​(if (first, 0D)) - Math.Abs ​​(if (seconds, 0D)). The type of this expression evaluates decimal ... no a decimal . Therefore, if the result of your entire if () expression is a decimal , and not a decimal? . Do you assign results to decimals? does not matter.

I do not understand if the if statement is not jumping to the right section and nothing is done in the variable total

this Well that's what it's doing. However, as mentioned earlier, in VB.Net can not specifies the value types before assignment, nothing is not converted to decimal, because the < Code> if () the result of the expression is in the case of a decimal, specify the value of not having anything in the default decimal value of 0D ... so your results

I have not tested, but I think your if () operator decimal clearly your desired outcome by casting false expression as Can you fix this to get it? / Nullable (of Decimals) . This decimal instead of if () expression decimal to tell the compiler to count, and so does not return anything that expression will be the desired output.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -