Click here to Skip to main content
15,887,485 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# Javascript in WebBrowser Pin
unfolded19-Apr-18 1:48
unfolded19-Apr-18 1:48 
GeneralRe: C# Javascript in WebBrowser Pin
Gerry Schmitz19-Apr-18 9:08
mveGerry Schmitz19-Apr-18 9:08 
QuestionWebBrowser script communication problem inside C # ActiveX Control Pin
SoulToMind15-Apr-18 22:01
SoulToMind15-Apr-18 22:01 
SuggestionRe: WebBrowser script communication problem inside C # ActiveX Control Pin
Richard MacCutchan15-Apr-18 22:28
mveRichard MacCutchan15-Apr-18 22:28 
GeneralRe: WebBrowser script communication problem inside C # ActiveX Control Pin
SoulToMind15-Apr-18 23:23
SoulToMind15-Apr-18 23:23 
AnswerRe: WebBrowser script communication problem inside C # ActiveX Control Pin
Gerry Schmitz16-Apr-18 7:59
mveGerry Schmitz16-Apr-18 7:59 
QuestionFixing divide by zero exception into a whole new problem Pin
Member 1377871513-Apr-18 13:56
Member 1377871513-Apr-18 13:56 
AnswerRe: Fixing divide by zero exception into a whole new problem Pin
Luc Pattyn13-Apr-18 15:26
sitebuilderLuc Pattyn13-Apr-18 15:26 
Hi,

you tricked yourself in this one. First some comments, as requested:

1.
property Denominator throws when the value is zero, yet without parameters you create a Fraction with denominator zero??? This should be 1 IMO.

2.
Inside Reduce() you apply a brute force approach by trying each and every possible common divisor. Rather than trying them all in ascending order, you should use descending order and stop as soon as you find one.

3.
Again, inside Reduce(), you also try divisor 1, which always will be a common divisor. Such test is unnecessary, and so is the if (GCD != 0) test, as GCD will be 1 or larger.

4.
In the setter half of Denominator you fail to set anything.

5.
Now check the casing inside your Fraction(int num, int den) constructor!
Please check why several of the above issues are relevant to your program's current symptom.

6.
When you fixed all of the above, then consider entering some negative numbers, and check whether your program fails for negative denominators; fix if necessary.

7.
Rather than using Convert.ToInt32() you should use int.TryParse() which takes a bit more code but offers an indication the text actually is/isn't representing a valid number, so you can act accordingly.

8.
Needless to say, there are much better algorithms to determine a GCD, e.g. Euclid's.

Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum


modified 13-Apr-18 22:11pm.

GeneralRe: Fixing divide by zero exception into a whole new problem Pin
Member 1377871513-Apr-18 16:38
Member 1377871513-Apr-18 16:38 
GeneralRe: Fixing divide by zero exception into a whole new problem Pin
Luc Pattyn13-Apr-18 16:46
sitebuilderLuc Pattyn13-Apr-18 16:46 
GeneralRe: Fixing divide by zero exception into a whole new problem Pin
Member 1377871513-Apr-18 17:02
Member 1377871513-Apr-18 17:02 
SuggestionRe: Fixing divide by zero exception into a whole new problem Pin
Richard Deeming19-Apr-18 1:39
mveRichard Deeming19-Apr-18 1:39 
QuestionNull values from sql server database are displayed #VALUE! in Excel Pin
Gtari Abir13-Apr-18 6:09
Gtari Abir13-Apr-18 6:09 
AnswerRe: Null values from sql server database are displayed #VALUE! in Excel Pin
OriginalGriff13-Apr-18 6:31
mveOriginalGriff13-Apr-18 6:31 
AnswerRe: Null values from sql server database are displayed #VALUE! in Excel Pin
mecoder8915-Apr-18 22:01
mecoder8915-Apr-18 22:01 
AnswerRe: Null values from sql server database are displayed #VALUE! in Excel Pin
Gtari Abir16-Apr-18 0:27
Gtari Abir16-Apr-18 0:27 
QuestionNeed help with Functions, ASAP! Pin
Member 1377783813-Apr-18 1:30
Member 1377783813-Apr-18 1:30 
AnswerRe: Need help with Functions, ASAP! Pin
Keviniano Gayo13-Apr-18 2:01
Keviniano Gayo13-Apr-18 2:01 
AnswerRe: Need help with Functions, ASAP! Pin
#realJSOP13-Apr-18 4:14
mve#realJSOP13-Apr-18 4:14 
AnswerRe: Need help with Functions, ASAP! Pin
#realJSOP13-Apr-18 6:23
mve#realJSOP13-Apr-18 6:23 
AnswerRe: Need help with Functions, ASAP! Pin
Eddy Vluggen13-Apr-18 6:45
professionalEddy Vluggen13-Apr-18 6:45 
AnswerRe: Need help with Functions, ASAP! Pin
Gerry Schmitz13-Apr-18 7:15
mveGerry Schmitz13-Apr-18 7:15 
AnswerRe: Need help with Functions, ASAP! Pin
#realJSOP13-Apr-18 7:49
mve#realJSOP13-Apr-18 7:49 
AnswerRe: Need help with Functions, ASAP! Pin
BillWoodruff13-Apr-18 7:51
professionalBillWoodruff13-Apr-18 7:51 
GeneralRe: Need help with Functions, ASAP! Pin
#realJSOP13-Apr-18 7:53
mve#realJSOP13-Apr-18 7:53 

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.