Posts by Maniero • 444,682 points
6,921 posts
-
1
votes1
answer60
viewsA: What is the difference between stack frame and Execution context? Are they the same thing in Javascript?
The information is a bit flawed. It is not wrong, it is even this, but "execution context" is something broader. There are several execution contexts, which in a way we can call scope (I don’t know…
-
8
votes3
answers557
viewsA: Continue loop if input is’S'
You probably want me to ask inside the loop as well, and you’re only accepting entering with lowercase, if you want uppercase (as per comment) you have to do: continuar = input("Deseja continuar? ")…
-
1
votes1
answer78
viewsA: Calculator is not capturing the second number
The biggest problem is that you are putting the text in the formatter of scanf(), there is only to have a data input pattern and not a text, including because the text was already written. There are…
-
5
votes2
answers164
viewsA: What would this . f be in Javascript?
what would this f A member of an object created at this time, like any other with nothing special. Or if you prefer it is an element of a array associative that passes as object, which is what are…
-
1
votes1
answer48
views -
5
votes2
answers174
viewsA: Formatting values per Razor pages
Do so: using static System.Console; using System.Globalization; public class Program { public static void Main() { var valor = "9.5789"; WriteLine($"Custo: R${valor:C2}"); WriteLine($"Custo:…
-
16
votes2
answers210
viewsA: How does an "if" work internally?
Let’s say there was no command block, so it would look something like this (no optimization): var x = 8; if (x < 4) goto TRUE; print("x é maior do que 4!"); goto FIM; :TRUE print("x é menor do…
-
1
votes1
answer53
viewsA: Code ". exe" stopped working
You are creating the array (the way it is done in C and not C++) right at the beginning of the code with the size 1. Then you try to fill this array n times, that is, after doing it the first time…
-
4
votes1
answer143
viewsA: Why are instance variables usually initialized in the constructor?
First, you are using a wrong nomenclature, but it is not your fault, almost everyone uses wrong, see in What is the difference between attribute and field in the classes?. The example is terrible…
-
2
votes1
answer75
views -
9
votes3
answers1299
viewsA: Define whether the letter is vowel or consonant
The code has several errors. One of them is that it gives a break before returning something, then ends up returning to another, the break has to be the last instruction of the block, but if you’re…
-
7
votes4
answers1090
viewsA: How to create an array filled with values from 0 to n in javascript?
There’s no miracle, the only thing is that I think it’s silly to use forEach(), took fashion people do this but has zero need, is a complicator, usually leave longer and certainly slower without…
-
2
votes1
answer54
viewsA: At the last run of the repeat loop the entered value is assigned to my counter
The main problem is that you are asking for 10 values but are reserving space only for 9 in array. Of course there is also no validation of the typed data so strange things can happen in the…
-
3
votes2
answers81
viewsA: Concatenate string of variables
Put a else in each if and initialize variables with the value '' so it will always have a value. Even the if s are chained. In fact it would be even better to use the conditional operator and…
-
4
votes2
answers373
viewsA: Java square (geometric figure)
I would do so: class Main { public static void main(String[] args) { int altura = 5; int largura = 5; for (int j = 0; j < largura; j++) System.out.print("* "); System.out.print("\n"); for (int i…
-
5
votes1
answer202
viewsA: What is a convention on configuration?
It means that the tool is opinionated, that is, it decides what is good for you in most cases. In general are decisions made by skilled and experienced engineers with that problem and know how it is…
-
12
votes2
answers219
viewsA: Why do we use a "get" before declaring a function in Angular?
This has nothing to do with Angular, this can by chance use this, has to do with Javascript. This method uses a project pattern called getter (has the Setter also). In some languages this standard…
-
11
votes2
answers568
viewsA: "Alert", "confirm" and "prompt" are considered bad practices?
It is not that it is bad practice, because good or bad practice is an excuse of those who do not know what they are doing. Think about it, what does good practice mean? A cake recipe someone told…
-
2
votes4
answers729
viewsA: How to get the month formatted with zero left in Typescript
Just create a variable just for that, Typescript is not Javascript, each variable has a type of can not change, IE Typescript is not messy: let month = new Date().getMonth() + 1; let todayMonth =…
-
1
votes1
answer76
viewsA: Why is the result of this mini program 2?
The variable Q points to the memory position equal to the address of P, so the beginning of array, one more shift of 8 positions according to pointer arithmetic, then it is position 8 that has value…
-
14
votes3
answers246
viewsA: What is a modal?
Modal is a screen (window) that blocks the main screen (window). It opens on top of a screen and does not allow you to interact with the parent screen until you complete the action that the modal…
-
2
votes1
answer216
viewsA: Why do we use the type "Static" in a function in Typescript?
He’s an access modifier, not a type, in this case the method is without type. More generally we can say that it is an attribute of the member of a class, in this specific case of a class method. The…
-
1
votes1
answer171
viewsA: How to return a specific element within an array?
Would this be: return vector[3]; which is the last element of this array (since it starts at 0). I put in the Github for future reference. If the quantity is variable then you have to take the…
-
2
votes1
answer63
viewsA: Why isn’t this program running the commands inside the second function on?
There are a huge amount of errors in the code, apart from the disorganization. I won’t fix them all. Simplifying and modernizing: using static System.Console; namespace EX7 { class Program { static…
-
10
votes2
answers231
viewsA: What does " | " mean in Typescript?
This is used in something called Union types (united types) also called sum types, as opposed to product types or intersection types (intersected types*) that uses the syntax of &. It is still…
-
2
votes2
answers74
viewsA: Create methods in classes to manipulate fields
This is what we call methods getters/Setter. There are controversies about its use and almost always people use wrong (read everything, including the links). In C# if you want to reproduce them…
-
9
votes1
answer133
viewsA: Why do we use "<>" in Typescript?
This is to indicate a type parameterization, also known as Generics (some like to call Diamond Operator but he’s not an operator. It works like the parentheses of a function, in fact it is very…
-
4
votes1
answer218
viewsA: Why do we use "void" typing in Angular?
void means something non-existent. It is not something specific to Angular but Typescript, actually even in the vast majority of static typing programming languages. By simplifying the languages…
-
3
votes1
answer78
viewsA: Fastest way to calculate a/b+c/d with float
It’s hard and it’s easy. Universally it’s difficult because every architecture, including its versions, can make a lot of difference. Not only that, the compiler you are using and linked options can…
-
3
votes1
answer106
viewsA: Constant used within repeat loop
Create an array with 20 positions (textElement1, textElement2... textElement[n])? No, you must be confusing what this object is. It is a manipulator of the GIFT, even is the GIFT, so it has a form…
-
2
votes1
answer116
viewsA: Is Sqlserver’s HASHBYTES() function cryptographically secure?
Yeah, it’s safe if you use the right algorithm, if you use salt, etc., use an SHA2, do not use MD and avoid the previous SHA. If you want to know more: How to hash passwords securely?.…
-
1
votes2
answers621
viewsA: How to use Enum.Parse()?
You shouldn’t use the Parse(), this is explained in Differences between Parse vs Tryparse. Using the TryParse() would look like this and it works: using System; using static System.Console; public…
-
7
votes1
answer247
viewsA: Size of a list list using list.Capacity
Yes, that’s right, by optimizing a list, in the current implementation, it starts with 4 elements and every time the capacity burst it doubles in size. When a list has no more capacity you need to…
-
3
votes1
answer54
viewsA: Difference between changing a variable and a recurring object
The difference is precisely the local variable and the field that is used in the return. The second example returns at the end the object field. Each execution of the function changes the field. The…
-
2
votes1
answer69
viewsA: Instantiate class within constructor
The above code, every time the user is using the login function, for example, it will start all classes right? or am I wrong? It will instantiate several objects of these classes within the…
-
7
votes3
answers325
viewsA: Is it possible to override a base class property?
Yes, it is possible. First make the property virtual: public class ClienteViewModel { [Required(ErrorMessage = "Preencha o {0} do Cliente")] public virtual string Celular { get; set; } } Then I’d…
-
1
votes1
answer197
viewsA: I want to enter a number and it’s multiplied from 1 to 10
The error is that not initializing the variable to use it, initiating would solve the problem. But this code can be simplified and the variable is not necessary, even there was a logic error making…
-
2
votes2
answers75
viewsA: How to print the two vector values in the pointer struct?
You are making some mistakes there. If you want to list a person pass a person and not all people. Then everything becomes simple and easy. Note that in addition to receiving only one person I am…
-
2
votes1
answer65
viewsA: Speech recognition is giving stack overflow
You are calling the method Speak() within the method Speak(). This is called recursion, so far without problems even if in most cases it is not necessary. Only at some point it needs to stop,…
-
2
votes3
answers752
viewsA: How to convert int variable to string without deleting zeros?
It’s simple, don’t convert to whole, if you already have the information the way you want it, then use it directly. If you need the conversion, do it after validating. In the end I did the…
-
3
votes1
answer2321
viewsA: What is None in Python?
None is nothing, is the lack of value. In case is printing this because the result of the function print() always is None because it is a function that only does an action and does not generate a…
-
2
votes1
answer248
viewsA: Association, aggregation, etc. in practice?
In practice you must learn the theory to understand this. People are so concerned with practice that they don’t understand anything they’re doing, they just follow cake recipe. The theory was passed…
-
3
votes2
answers95
viewsA: How do I set contacts for a Phone object?
You have a few options, one more suited to the name and signing of the method and the other more to what is normally done, and a variation of this. The first way is to create a array with these…
-
5
votes1
answer90
viewsA: Using static factory methods instead of constructors
The constructor problem is that it allocates memory to the object you want or not, with the factory method you decide what to do. In the case of Boolean it has 2 objects allocated and if you need to…
-
2
votes2
answers322
views -
7
votes1
answer104
viewsA: Is it recommended to explain all variables?
Broad rules, ambiguous and vague, help to think about the subject, but do not serve as something definitive of what should be done. This rule does not say what should be explicit. The rule is broken…
-
11
votes1
answer269
viewsA: What kind of . NET library should I choose in C#project?
For new projects you should only use .NET Core who will be the one who framework that will survive (see more). See more in The . NET Framework is dead?. I don’t know if it’s relevant yet, but... The…
-
3
votes1
answer213
viewsA: Stackoverflow error when compiling code in C#
The problem is the ToString(). Ali is calling himself at the time of returning something, then enters into infinite loop and breaks. I think you forgot to use the text object there, it would be…
-
2
votes1
answer102
viewsA: Is there a performance gain in concatenating strings directly into SQL?
First I have to say that these things are not easy to define like this, it is not something that can be easily inferred, just testing to know. Second, you need to see if you really need this…
-
2
votes1
answer311
viewsA: Fraction sum problem in C#
There are several errors there, starting with the interpretation of the text. I solved it in 2 lines (I switched to console to make it universal and simple, but just change the count there by the…