Posts by Maniero • 444,682 points
6,921 posts
-
12
votes1
answer924
viewsA: When does it make sense to have only static methods and attributes in a class?
Methods It is a matter of necessity. If you only have functions (another name of static method) that perform something alone or on top of some object that that function does not need to have more…
-
6
votes1
answer609
viewsA: Access values within an array from the index
There’s an object inside a array. First you access the element index (in case there is only one, then it is 0), then access the object member, as you did correctly. var x = [{ id: '1', name: 'name',…
-
4
votes1
answer89
viewsA: Might there be some error in the execution of foreach in this method?
I can’t talk about the right logic because I don’t know what to do, but there’s a basic error of the code itself. It is possible to have a null reference error, since the condition feature is…
-
2
votes2
answers1069
viewsA: Voice recognition does not work
I cannot say exactly how to solve the problem, but the error occurs because some component is missing, in this case what makes the recognition in Portuguese, which clearly does not come by default…
-
1
votes1
answer953
viewsA: References of Subs and Functions where it is being used disappeared in my Visual Studio
This feature is called Codelens. It can be enabled or disabled in Visual Studio settings (Tools -> Options). Note that this feature is only available on Visual Studio Enterprise or Professional.…
-
9
votes2
answers375
views -
4
votes1
answer133
viewsA: How to lease value without pennies down?
Divide by 10 and use the function intval() to take the whole part, it will lose the "broken" part, then multiply by 10 again to re-establish the magnitude. If you need to round up normally add up to…
-
4
votes3
answers419
viewsA: How to turn a bool into int?
You cannot understand the errors literally, in most bvezes the problem is another: you are using the wrong operator, the correct one is the && which is the AND logical. The & is the AND…
-
15
votes1
answer4119
viewsA: What is a multi-paradigm language?
I’ve already answered the paradigm of two opportunities: What is a paradigm? and in question where it had a specific context. The term already answers everything :P They are languages that support…
-
6
votes4
answers160
viewsA: How can I make a string code work with > or <?
The real problem throughout this code is that it is not handling the text data well. Something similar to what happens in the answer placed on another question. If you want to insist on using text…
-
8
votes5
answers993
viewsA: What is the difference between referencing an attribute directly or by get/set
There is no security breach allowing access to the fields (I don’t like the term attribute for this, further in this context). At most it is a encapsulation break, or abstraction leak, even so…
-
3
votes2
answers501
viewsA: Undefined variable
It’s very simple, it’s just a typo, write _POST instead of _post and will be solved. Uppercase and lowercase makes a difference in the name of variables. The rest is pure invention. Programming is…
-
8
votes1
answer852
viewsA: How to change null field to not return anything?
Use the function COALESCE: COALESCE(coluna, '') The result of this function is the first of the two arguments that is not null, so if the first is not, it takes the value of the column, otherwise it…
-
9
votes2
answers4065
viewsA: What are modules in programming?
There is no single definition. Each context, each technology can define it in a different way. So the dictionary definition can help more than a specific definition. It can be seen in Priberam or…
-
6
votes3
answers1957
viewsA: Cannot implicitly Convert type 'Object' to 'int'. An Explicit Conversion exists (are you Missing a cast?)
I decided to answer because the answer accepted is a mistake and the other talks about good practices, when it is just the opposite. Either it works right or it doesn’t work, there is no good…
-
10
votes2
answers618
viewsA: How to list methods of a class in C#?
This is done with reflection. Specifically with the method GetMethods() class Type. It is possible to filter them as you wish, either through the method itself or with the array of the kind…
-
9
votes2
answers153
viewsA: Is there any way to run C# from the command line in interactive mode?
There have been a few options for quite some time now official component working together with Visual Studio 2015 Update 1 forward (but you don’t need it to work). More information on Scott…
-
9
votes2
answers228
viewsA: Is there any functionality similar to Assert (affirmations) in C#?
There is the Assert() how do you know. Depending on the framework of tests you use. You may have many others. The . NET has contracts also. Can be useful in some scenarios where people use assert…
-
30
votes2
answers1642
viewsA: Is Eval a good guy or a bad guy?
I’m going to start by saying that people use libraries without knowing if they have quality or not. Thus, how they use techniques, tools, methodologies, paradigms, technologies, courses, etc.…
-
7
votes2
answers189
viewsA: How to calculate the distance in fewer lines?
Without doing very crazy things and damaging the readability, there is very little that can be done. You can declare the two variables on the same line, reduce the blank lines and unnecessary…
-
10
votes1
answer1205
viewsA: Do I need to use Try/catch throughout a process chain?
It depends on the need. That’s one of the things you can’t answer without seeing the actual code, the specific situation. There’s no magic formula, "good practice," or anything like that. You have…
-
4
votes1
answer630
viewsA: How to use a counter inside a Hashmap?
To initialize the counter just put zero, as you would normally do. To increment you have to take the current value and already know that you do this with the method get() and to put the new value…
-
2
votes1
answer1149
viewsA: "Finish" method in Java
The method is called by the Java garbage collector when it goes into action. Note that it is present in all Java objects, since it is implemented by type Object of which all reference types are…
-
4
votes1
answer102
viewsA: A comparison between 2 char(s) is wrong
The code has some problems. The main thing is to use the operator == to compare strings. In C a string is just a string and needs a proper function to compare all of them and return whether it is…
-
6
votes2
answers691
viewsA: Gets() function for float value
First, you should never use gets() for nothing, it is a problematic function, not portable and considered obsolete. This is one of the many things they teach wrong around. The solution is to use the…
-
14
votes2
answers22374
viewsA: How do I delete commit from a branch in Git?
It’s essentially almost that even if you want to delete the commit current. Probably what you want is to return to commit previous, then need to catch the current - 1: git reset --hard HEAD~1 If you…
-
1
votes2
answers331
viewsA: Is there any way I can change the range of the Rand function in the middle of the C code?
The code has some problems. The main thing is to use the operator == to compare strings. In C a string is just a string and needs a proper function to compare all of them and return whether it is…
-
10
votes2
answers664
viewsA: What are the advantages of Parallel.Foreach in C#?
Her name pretty much gives away everything that’s being asked. This way the iteration in a sequence of items is evaluated in parallel, as far as possible, and in some scenarios this can take…
-
3
votes1
answer321
viewsA: How to create an array of roulette colors?
This code does not seem to have anything to do with the statement. I wrote a code according to what I understood. Whether it is large or not, even or odd can be discovered by normal checking using…
-
6
votes4
answers3023
viewsA: Rand between numbers with comma
Just use the standard library functions available for random number generation: random_device seed; mt19937 gen(seed()); uniform_real_distribution<float> dis(-270.33, -47.5); cout <<…
-
6
votes2
answers235
viewsA: How to create a cross-platform app?
Basically you need the .NET Core *currently only . NET itself, but it is not the Framework) that is the new implementation of .NET. It works on the three main desktop operating systems. For mobile…
-
3
votes4
answers2166
viewsA: How to know the number of lines a large file has in php?
You have to read it in Chunks data. Something like this: $file = fopen("teste.txt",'r'); $count = 0; while (!feof($file)) { $line = fgets($file, 4096); //provavelmente eu colocaria um valor maior,…
-
15
votes3
answers394
viewsA: What are friendly Urls?
Definition Sane Urls or Uris easier to read. They adopt the commonly used folder structure to indicate about the content, including the parameters used to get to that specific content. It is the…
-
1
votes1
answer68
viewsA: How to create a standard map chart?
Yes, it is possible to do this in C. It is possible to do it in any programming language that accepts calling external code in some way. Normally you will use some library that does this. It is…
-
3
votes1
answer1991
viewsA: Is it possible to use . htaccess with IIS?
It is possible partially with specific utilities, but the recommendation is to make a conversion and use the web.config which is the equivalent for him. Has online converter (another), but I don’t…
-
5
votes1
answer283
views -
6
votes1
answer550
viewsA: Can one override in builders?
The way you’re trying to make it like the constructor is a method is not possible. A builder is not polymorphic and inheritance takes place otherwise. It can be said that there is an inheritance…
-
4
votes1
answer246
viewsA: Problem to assign more than one value to variable
It is not possible to store two values in the same variable of a scalar type as in the case of integers. Nor does it seem useful to do this in this code. Of course, I know it can be an exercise that…
-
3
votes1
answer1578
views -
6
votes2
answers897
viewsA: How to filter items that do not contain a word in a list?
The algorithm presented in link is wrong. You’re looking for the phrase within words, it’s not going to work at all. You can’t look for a larger text inside a smaller one, the larger one will never…
-
5
votes2
answers5070
viewsA: How to display a certain position of an associative array?
You do it with function array_keys(). foreach (array_keys($vetor) as $index => $key) echo $index . ": " . $key . " => " . $vetor[$key] . "\n"; $array = array_keys($vetor); for ($i = 0; $i…
-
3
votes1
answer124
views -
6
votes1
answer1018
viewsA: Minify HTML code
First, minification is an act of transformation. If someone does not know, transforming is changing, changing the form. There is no definition of what you are referring to. What changes is…
-
7
votes5
answers210
viewsA: Variable is not displaying the expected result
The biggest problem is that some values that apparently need to have decimal parts are being treated as integers. Another problem is the lack of initialization of variables: #include <stdio.h>…
-
5
votes2
answers569
viewsA: Return Datareader to bool field
Just do this: ADMINISTRADOR = reader["ADMINISTRADOR"] as string == "S"; //se tem S ou N I put in the Github for future reference. Since the column is not originally a boolean but a text, it should…
-
5
votes1
answer979
viewsA: Function that converts hexadecimal to binary
Yes, the type conversion functions allow you to use the base you need: Convert.ToString(Convert.ToInt32("4F56A", 16), 2) Behold working in the ideone. And in the .NET Fiddle. Also put on the Github…
-
3
votes1
answer159
viewsA: Run an Attribute constructor
Understand how this decorator works. To call all attributes of all methods it is necessary to have a code somewhere that attributes are "called". This is done through reflection that will read the…
-
6
votes1
answer124
viewsA: Is it a good practice to have the same name with the column name of the bank?
You could say it is. If no problem cause is a good practice. But like all "good practice", it is only valid when the person knows what they are doing. When one does not understand why it is being…
-
5
votes1
answer461
viewsA: Word to number conversion and vice versa
I will keep this answer here because it can help someone, the question was better clarified in the comments and the problem was another. But the other cannot be solved without having criteria to…
-
7
votes1
answer1177
viewsA: Speed difference in HD Sata/SSD
First I will consider that the 500GB device is an SSD. Either it is SSD (Solid State Drive) or it is HDD (Hard Disk Drive). There is even the HDD sold as HDD SSD, but in the background it is just an…