New answers tagged

0

Consider making the settings more readable and strong-typed: public enum Modes{ Mode1 = 1, Mode2 = 2, Mode3 = 4, Mode4 = 8, } public class Config { private Modes configVal; public void SetConfig(Modes modes){ this.configVal = modes; } public bool AreAllSet(Modes modesAllSet) { return ((int)this....


0

This one might be faster reducing allocations amount. Also some naming issues were fixed. // avoid using fields where possible, it makes the code portable and reusable public void MainAlgorithm(List<double[]> xs, List<double[]> ys) { //this line replaces GetSmallestArray method, Linq is fine here while xs.Count isn't a large number double[...


0

I am going to expand upon @OlivierJacot-Descombes answer and offer an alternative. You do not have to limit yourself to a single method signature. And you do not have to use a BitArray. My answer is strictly offered as an alternative but I make no claim as to performance. But since the backing data storage to a BitArray is an internal int[], much of the ...


0

You could use a params array to pass the parameters public void SetConfiguration(params bool[] modes) { var setBits = new BitArray(8); for (int i = 0; i < modes.Length; i++) { setBits.Set(i, modes[i]); } byte[] byteSet = new byte[1]; setBits.CopyTo(byteSet, 0); _mode = byteSet[0]; } You might want to add tests to ...


0

You don't need to use Regex for this, and your regex doesn't cover most of cases anyway. You can simply splitting the input and try parse them into decimals. If they contains any invalid inputs then return three spaces (" ") otherwise print it in "00.000/00.000" format. Function StringFormatting(input As String) As String Dim parts = ...


0

It really depends, how far you want to go with this. Maybe the most common suggestion that I can give is that what you are doing is called Memory Caching. It's good to call things with a name that is widely understood. Read this article about In memory caching in Asp.net core. Just to give you an example, what can be a possible issue with your code. Let's ...


Top 50 recent answers are included