Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It's very hard to tell if there's anything wrong and what it might be - it looks like subtle problem.</p> <p>However, it might be easier to get a handle on these things if you refactor your code. There are many things in the code you've shown that make it harder than necessary to reason about what's happening.</p> <ul> <li>You're using <code>float</code> and <code>decimal</code> - <code>float</code> isn't that accurate but small and fast; <code>decimal</code> (tries) to be precise but especially is predictable since it rounds errors the way a human might in base-10 - but it is quite slow, and is usually intended for calculations where precise reproducibility is necessary (e.g. financial stuff). You should probably use <code>double</code> everywhere.</li> <li>You've got useless <code>else {}</code> code in the <code>Stripper</code> class.</li> <li>Your <code>Stripper</code> is an instatiable class, when it should simply be a static class with a static method - <code>Stripper</code> is stateless.</li> <li>You're catching exceptions just to rethrow them.</li> <li>You're using <code>TryParse</code>, and not checking for success. Normally you'd only use TryParse if you (a) expect parsing to fail sometimes, <em>and</em> (b) can deal with that parse failure. If you don't expect failure or can't deal with it, you're better off with a crash you learn about soon than a subtly incorrect values.</li> <li>In stripper, you're duplicating variables such as <code>_currentMot</code>, <code>currentMot</code>, and <code>param4</code> but they're identical - use only the parameter, and give it a logical name.</li> <li>You're using <code>out</code> parameters. It's almost always a better idea to define a simple <code>struct</code> and return that instead - this also allows you to ensure you can't easily mix up variable names, and it's much easier to encapsulate and reuse functionality since you don't need to duplicate a long call and argument definition.</li> <li>Your string parsing logic is too fragile. You should probably avoid <code>Replace</code> entirely, and instead explicitly make a <code>Substring</code> without the characters you've checked for, and you have some oddly named things like <code>test1</code> and <code>test2</code> which refer to a <code>lastChar</code> that's not the last character - this might be OK, but better names can help keep things straight in your head too.</li> <li>You have incorrect code comments (<code>decimal convTemp; //corrente resistenza</code>). I usually avoid all purely technical code comments; it's better to use descriptive variable names which are another form of self-documenting code but one in which the compiler can at least check if you use them consistently.</li> <li>Rather that return 4 possibly empty values, your <code>Stripper</code> should probably accept a parameter "sink" object on which it can call <code>AddT</code> <code>AddD</code> and <code>AddA</code> directly.</li> </ul> <p>I don't think any of the above will fix your issue, but I do believe they're help keep your code a little cleaner and (in the long run) make it easier to find the issues.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload