Posts by Maniero • 444,682 points
6,921 posts
-
6
votes1
answer1160
viewsA: What’s the difference between Vent and Delegate?
The event system is a much more powerful mechanism. It uses delegates as a basis but it does more than that. It is the implementation in the language of what is called Observer Pattern (example of…
-
7
votes1
answer167
views -
7
votes2
answers174
views -
4
votes2
answers2470
viewsA: Method with generic return
You have to call: String st = to(""); Integer it = to(0); And fix the method too: public <E> E to(E e) { return (E)e; } Behold working in the ideone. And in the repl it.. Also put on the…
-
8
votes2
answers1045
viewsA: Calculation to determine whether triangle is rectangle gives no expected result
There are two problems: You used = and not ==, to compare is the second, you have assigned a new value to the hypotenuse. You did not use the square root, so the formula is wrong. But there is a…
-
7
votes1
answer122
viewsA: Unexpected result in Lua test code
It’s totally consistent. You noticed that this step 6 makes two tests? First he executes test("masuia") and so the first line is printed. By then you should be finding everything right. Then it runs…
-
27
votes3
answers854
viewsQ: How to cancel a cancellation?
I believe that most software standardizes the use of the word "cancel" for a button whose action is to cancel the operation that is ongoing. Of course, the operation under way is the closest to…
-
13
votes3
answers1055
viewsA: Is there any performance gain when using ternary operator instead of a conditional operator?
Importance of performance PHP is a language where performance is not important, it is slow in much of its operations. So keep in mind that all information here is only relevant as curiosity. The…
-
38
votes4
answers35105
viewsA: Use of ? and : in PHP
This is called conditional or ternary operator. It works like a if. It tests a condition (the first operand), if it is true, the result of the operation is the first value (after the ?, the second…
-
3
votes1
answer557
viewsA: How to get command line parameters / file path
It has two forms. One with parameter no Main(): void Main(string[] args) { foreach(var arg in args) { switch(arg) { case "-r": //faz algo aqui case "-v": //faz algo aqui } } } And if you can’t do…
-
4
votes3
answers1771
viewsA: Code comments when working in a group
Most of what I could say has already been said in the answers here and in my answer in that question. Also read the other answers there, in a general way I agree with them. I do not think that what…
-
3
votes2
answers291
viewsA: Variable name passed in function argument
You can’t do this and there’s no reason to do it. Actually, there might be a way. I don’t know one specifically but since PHP is a basically interpreted language, it is possible that there is an API…
-
4
votes1
answer288
viewsA: Create different random password for each loop record
The problem seems to be just that the function geraSenha is inside the loop. Put it before all this code. function geraSenha() { //caracteres que serão usados na senha randomica $chars =…
-
2
votes1
answer850
viewsA: Run a query by clicking on the result of another query
The question has been edited and shows that there are several problems. In fact every question is compromised. You have two big problems, among several small ones that I won’t even try to solve. The…
-
4
votes2
answers99
viewsA: Preset in Javascript function parameters
This is usually called default Parameters. And Javascript does not allow this syntax. The best that can be done is to set values early in the function: function teste(oi, type) { oi = (typeof(oi)…
-
2
votes1
answer332
viewsA: How to format values with custom string formats?
The question has been changed and I will try to save the answer as far as I can. Use this: private void chart1_FormatNumber(object sender,…
-
8
votes2
answers344
viewsA: Split column into multiple tables
The two ways are possible. The most traditional is to use an extra table and normalize the gender register. This is the way normalized. In general you need to have a good reason to not normalize. In…
-
8
votes2
answers110
viewsA: index starting from right
The function you want is the lastIndexOf() console.log("asdhusaidhi asdhasuidhu".lastIndexOf('s')); I put in the Github for future reference.…
javascriptanswered Maniero 444,682 -
2
votes1
answer523
viewsA: Error creating a NOT NULL field in PGADMIN " contains null values "
The message itself gives a good indication of the problem. Two things can happen: You are creating a new column and you are not placing a value DEFAULT in it. In this way it can be null. Establish a…
-
15
votes1
answer484
viewsA: Data access performance in heap and stack and object allocation
Yes, the stack not only is it faster than the heap but it’s also easier to manipulate it. The allocation in heap is basically due to these reasons: An object is too big to fit in stack. The area…
-
5
votes4
answers374
views -
39
votes5
answers8000
viewsA: What is the difference between pointer and reference?
TL; DR Pointer is a low-level abstraction mechanism that contains a memory address for any object. This address is his focus and this value can be manipulated freely by the application as any data.…
-
11
votes1
answer280
views -
37
votes7
answers1131
viewsQ: Too many screens or a screen with too much information?
I see an increasing trend, although this has existed before, to create multiple screens, several steps to perform a single action. Of course, the advent of smaller screens encourages this. But I’m…
-
12
votes4
answers2538
viewsA: Should exceptions be used for flow control?
Exceptions should not be used for flow control There is no doubt that exceptions should not be used for flow control. There is a lot of literature on this. Even every Java programmer should know…
-
2
votes2
answers1247
views -
3
votes2
answers123
viewsA: Have a loop run again
You can do it like this: while (digita != 4) { System.out.println("Digite o o número referente ao tamanho da(s) pulseira(s)\n1.Pequena (17cm) - R$180,00\n2.Média (18cm) - R$200,00\n3.Grande (20cm) -…
-
18
votes4
answers1166
viewsA: What are the differences between Generic Types in C# and Java?
The questions have been answered in the two answers posted so far. I will add something extra that has not yet been said. In C# the type materialization occurs in Runtime and not at compile time as…
-
6
votes2
answers385
viewsA: In which scenario is it recommended to use Keyedcollection instead of a Dictionary?
You should use in the situation you need to access the elements of this collection in O(1) (finds what you want essentially at the same time, no matter the size of the collection) either by the…
-
6
votes3
answers185
viewsA: Problem with program that prints three numbers increasingly
This may not be the best way to do this but as I think you’re learning I won’t try to mess with your logic too much. I will solve two problems existing in it. The first is that you can’t make a…
-
1
votes1
answer453
viewsA: itt' is not recognised
I’ll respond based on the information you’re passing on. I do not know if you will be able to apply since you are having very basic difficulties to use the compiler. It looks like you are using a…
-
7
votes1
answer577
viewsA: How to count touches (letters, spaces and symbols) in PHP?
The simplest solution is to use the function mb_strlen() that is prepared to handle characters multibyte as is the case with UTF-8. mb_strlen("FUNÇÕES") // produz 7 Behold working in the ideone. And…
-
2
votes3
answers4033
viewsA: Undefined reference compiling with g++
Change this: template <class T> class elemento { public: T dado; elemento<T> *prox; }; You cannot access private class data. Remember which classes have their private members by default,…
-
9
votes3
answers2007
viewsA: How to obtain information from an SSL Certificate via C#?
In accordance with the page that I put in the comment and the documentation you can get all information instantiating a certificate object X509: using static System.Console; using System.Text; using…
-
1
votes1
answer66
viewsA: I can’t see which argument I should use to do this job
If I understood the problem the solution would be this: private List<RetornoRomaneioPostagem> BaixadoNRetornado(List<RetornoRomaneioPostagem> baixasNRetornadas) { try { var…
-
3
votes2
answers1047
viewsA: Error while running project in Visual Studio
This message is showing that there was an exception but it was manipulated by the component you are using. Most of the time you don’t have to do anything and it won’t happen when you’re not…
-
11
votes2
answers14623
viewsA: What is and what is "2>&1" for?
1 means the same as stdout and 2 means the same as stderr, so it’s just a simpler way to redirect everything that is sent to the error output to the standard output. The & is necessary to avoid…
-
10
votes1
answer2080
viewsA: Random() generating repeated numbers
Yes, there is. Your code is initiating the random seed every time inside the loop. So it will repeat itself. If you want different values you should start the seed only once, that is, you should…
-
5
votes3
answers389
views -
7
votes2
answers11135
viewsA: Exception vs Runtimeexception, when using one or the other?
RuntimeException should be used when the exception can be prevented. Use it indirectly when you want to signal to the user programmer of your code that it can try to solve the problem when this…
-
7
votes1
answer474
viewsA: How to make a query that returns data from the last 7 days without considering Sunday
You didn’t give too many details, I think what you need is something like this: SELECT SearchId, getdate() as CreateDate FROM Security.Search WHERE DATEDIFF(DAY, CreateDate, GETDATE()) < 8 AND…
-
6
votes1
answer1927
viewsA: Build GUI for Windows without using Windows API
If these softwares were not made with . NET, and as far as I know they haven’t, they don’t really use Windows Forms, which is nothing more than a layer on top of the Windows API. When you want to…
-
4
votes1
answer170
viewsA: How is the Linux kernel or programs written in C tested?
In thesis one can use any test methodology and any tool that helps this process in C can be used. In Java you use Junit, other programmers use something else. As far as I know Autotest is used by…
-
9
votes1
answer2771
viewsA: How to get computer information with C#?
The question is a little wide. I will show you the path that is most important. If you have specific questions you can ask specific new questions. Keep in mind that not all information can be…
-
4
votes1
answer214
viewsA: Cannot find Symbol - variable calories
You are declaring the variables within the if then they only exist within it, when it comes out, they no longer exist. You need to learn about scope (this gives an introduction but to learn it would…
-
6
votes2
answers331
viewsA: Check string value
The code has some problems. You are asking to type in the singular and comparing with the plural. And worse, it has to be with the first letter capitalized. Besides this you are not comparing two…
-
8
votes2
answers299
viewsA: C operator precedence table
You have several priorities there. The first thing that will be executed is y = 2 This statement ends there because of comma operator. Then the code executes y + 3 As before the y value 2, now it is…
-
2
votes2
answers250
viewsA: Repeat loop is not running
You are not restarting the variable num which is used as an accountant. It has two solutions: while (num < n1) { printf ("%d ", vet[num]); num++; } num = 0; while (num < n1) { if (vet[num] ==…
-
2
votes2
answers344
views -
5
votes2
answers390
viewsA: Why can’t an anonymous method be assigned to a var or Dynamic?
Miguel Angelo’s answer already answers the question. I’ll just post some information that might help find some other solution in some cases. Of course, for the question, the simplest and most…