Click here to Skip to main content
15,891,375 members
Home / Discussions / C#
   

C#

 
Questionappend node by element name Pin
Jassim Rahma18-Mar-10 11:43
Jassim Rahma18-Mar-10 11:43 
AnswerRe: append node by element name Pin
Not Active18-Mar-10 12:10
mentorNot Active18-Mar-10 12:10 
AnswerRe: append node by element name Pin
carlecomm18-Mar-10 15:44
carlecomm18-Mar-10 15:44 
AnswerRe: append node by element name Pin
Mirko198018-Mar-10 22:27
Mirko198018-Mar-10 22:27 
QuestionHow do I call a method on the parent form from another form? Pin
Paul Stol18-Mar-10 10:09
Paul Stol18-Mar-10 10:09 
AnswerRe: How do I call a method on the parent form from another form? Pin
T M Gray18-Mar-10 10:46
T M Gray18-Mar-10 10:46 
AnswerRe: How do I call a method on the parent form from another form? Pin
DaveyM6918-Mar-10 11:15
professionalDaveyM6918-Mar-10 11:15 
QuestionQuestion with converting double to long Pin
Fenryl18-Mar-10 9:19
Fenryl18-Mar-10 9:19 
Hi to all! I'm having the following problem and I would like some help on trying to solve it.

I'm trying to correct a problem I detected in a code from a project I'm working on (the code is not mine and since the person who made it is no longer in the team I have no way of knowing why this was made this way).

I've spoted a cast from double to long that doesn't seem to work out very well. The idea is to convert the double value to a long so that it can be compared between two other longs (max and minimum values in a specific scale). The code is something like this:

minValue = 56;
maxValue = 70;

value = 55.99.

if ((long) value >= minValue && (long) value <= maxValue)
{
....
}


The problem is that the cast makes value to be 55, instead of 56. Checking other alternatives, I saw Convert.ToInt64, that, for this example works. However, it does not work the way I wanted if the value is say, 70.5, in this case I'm stuck with 70, when I would like to have 71, like I saw on MSDN ("If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.").

Can anybody point me to the correct way of converting a double to long, without this problem with rounding the even numbers?

Thanks in advance!
AnswerRe: Question with converting double to long Pin
Alaric_18-Mar-10 9:35
professionalAlaric_18-Mar-10 9:35 
GeneralRe: Question with converting double to long Pin
#realJSOP18-Mar-10 9:44
mve#realJSOP18-Mar-10 9:44 
AnswerRe: Question with converting double to long Pin
#realJSOP18-Mar-10 9:46
mve#realJSOP18-Mar-10 9:46 
AnswerRe: Question with converting double to long Pin
Luc Pattyn18-Mar-10 9:55
sitebuilderLuc Pattyn18-Mar-10 9:55 
GeneralRe: Question with converting double to long Pin
Richard MacCutchan18-Mar-10 10:34
mveRichard MacCutchan18-Mar-10 10:34 
GeneralRe: Question with converting double to long Pin
Alaric_18-Mar-10 10:35
professionalAlaric_18-Mar-10 10:35 
GeneralRe: Question with converting double to long Pin
Luc Pattyn18-Mar-10 11:06
sitebuilderLuc Pattyn18-Mar-10 11:06 
AnswerRe: Question with converting double to long Pin
AspDotNetDev18-Mar-10 10:53
protectorAspDotNetDev18-Mar-10 10:53 
AnswerRe: Question with converting double to long Pin
PIEBALDconsult18-Mar-10 16:22
mvePIEBALDconsult18-Mar-10 16:22 
Question(2.0) ...wanting to show/hide control within a GridView's TableCell.Controls collection. [modified] Pin
Alaric_18-Mar-10 7:57
professionalAlaric_18-Mar-10 7:57 
AnswerRe: (2.0) ...wanting to show/hide control within a GridView's TableCell.Controls collection. Pin
Alaric_18-Mar-10 10:44
professionalAlaric_18-Mar-10 10:44 
QuestionProblem running deployed application online only - C# .NET 3.51 Pin
Jon Braunsma18-Mar-10 7:42
Jon Braunsma18-Mar-10 7:42 
Questiondegrees to MILS Pin
v17.poornima18-Mar-10 6:47
v17.poornima18-Mar-10 6:47 
AnswerRe: degrees to MILS Pin
PIEBALDconsult18-Mar-10 6:58
mvePIEBALDconsult18-Mar-10 6:58 
GeneralRe: degrees to MILS Pin
Luc Pattyn18-Mar-10 8:16
sitebuilderLuc Pattyn18-Mar-10 8:16 
AnswerRe: degrees to MILS Pin
Keith Barrow18-Mar-10 7:48
professionalKeith Barrow18-Mar-10 7:48 
AnswerRe: degrees to MILS Pin
Saksida Bojan18-Mar-10 7:51
Saksida Bojan18-Mar-10 7:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.