Posts by Maniero • 444,682 points
6,921 posts
-
8
votes2
answers81
viewsA: If I call a Javascript file, is that code visible in the browser (browser)?
Yes, there’s nothing I can do to stop this. Take the test.
-
3
votes1
answer202
views -
14
votes2
answers1211
viewsA: What is the difference between using (int)variable or Convert.Toint32(variable)?
Cast The (int) is an operator of cast. It should only be used when there is certainty that the conversion will be successful. It can also only convert numeric values. In the example, used the cast…
-
5
votes1
answer3938
views -
2
votes2
answers94
viewsA: Simplify LINQ p => p.Tipo.Toupper(). Equals("S") && p.Modo.Toupper(). Equals("S")...,n
You’ll probably wonder if this is simpler. But it is, though it’s bigger. And it’s the right way, although I doubt whether the right way should be used. p => p.Tipo.Equals("S",…
-
6
votes2
answers3291
viewsA: Obtain the number of decimals of one decimal
It has more "elegant" solutions using pure mathematics, but they would be much more complicated (someone might be tempted to do a simple operation and it won’t work for all situations). The simplest…
-
8
votes2
answers323
viewsA: What is the @ in a view and controller for?
In the view using the rendering engine Razor it indicates that the following is a C# code and not HTML, and so it will need to be executed and the result of this execution is that it will be…
-
4
votes2
answers387
viewsA: How to return strings that are in crescent date format in Sqlite?
Record in format SimpleDateFormat("yyyy/MM/dd"). The most significant value - the year - must come before and the least significant - the day - must come at the end. It’s basic math to make…
-
7
votes4
answers844
viewsA: How to create properties dynamically in C#?
Current responses do not simulate exactly what happens with JS. It can even achieve a similar (and not equal) result, but in a very different way. So it simulates correctly: using static…
-
1
votes1
answer54
viewsA: Strict Mode in Javascript works in frameworks?
It depends on the case. But the frameworks more modern are usually compatible and even make extensive use this way. The older ones have started to adapt but have to analyze case by case. jQuery and…
javascriptanswered Maniero 444,682 -
2
votes2
answers2523
viewsA: Removing blanks from a string
Has algorithm ready in the library that makes the work much easier: #include <iostream> #include <string> #include <algorithm> using namespace std; int main() { string str = "…
-
11
votes1
answer374
viewsA: What is ADO.NET for C#?
You can use any language that is compatible with .NET. C# is the main one. Has basic information in our tag. And the official page. Wikipedia. It is the basic database access mechanism used by .NET.…
-
10
votes3
answers18966
viewsA: Browse objects with pure Javascript
Basically this is it: var objeto = [ 1, 2 ]; for (var chave in objeto) console.log(objeto[chave]); You may want to get better if you’re picking up unwanted members: var objeto = [ 1, 2 ]; for (var…
-
4
votes1
answer1858
viewsA: In C/C++, what are the build directives for? When should I use them?
They are processed before the compilation of the code itself. In general they instruct the compiler of some actions that should be done with the code. In this particular example the conditional…
-
2
votes1
answer2020
viewsA: Program requesting libgcc_s_dw2-1.dll
This DLL is required to use GCC on Windows and must track all of your applications (unless it is in a path that can be found) ,then copy it along with your application, or put where it has on PATH.…
-
4
votes1
answer152
viewsA: Typing a pointer to struct
You declared the variable but did not assign any value to it. Then you tried to modify its value. This generates error. You have to initialize the variable. Because it is a pointer, the…
-
7
votes1
answer718
viewsA: Why should I use the Stringbuilder class instead of the String class?
Basically to avoid the problem of Shlemiel the Painter’s Algorithm. To string in C# is immutable. When you add new parts to string, it is necessary to make a new memory allocation and copy all…
-
51
votes6
answers16518
viewsA: What does NULL really mean?
The question was edited when there were already several answers, including one that was most appropriate to her initial scope. It’s still valid, but I need to put this on for those who don’t…
-
33
votes2
answers17491
viewsA: What does software scalability mean?
Scalar means to climb. So scalability, in this context, is the ability to increase the size of the software or its use. When we talk about the scalability of software itself we’re talking about…
-
9
votes4
answers205
viewsA: How do you round it up in PHP?
Use the function ceil(). echo ceil(1.1); Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.…
-
10
votes1
answer11054
viewsA: Streamwriter Special Characters with Encoding.ASCII C#
The encoding the simplest that solves your problem is Latin1 (see table). In place of ASCII would use: Encoding.GetEncoding("iso-8859-1") or Encoding.GetEncoding(28591) I put in the Github for…
-
5
votes6
answers498
viewsA: What is the safe way to define a default value for a function parameter?
Really the value default was recently introduced and few browsers support it (a few years later this is already less important and has solutions polyfill that if they are well implemented can solve…
-
7
votes1
answer1373
viewsA: How to handle duplicate key error?
I think this is what you need. try { context.Produto.Add(_produto); context.SaveChanges(); } catch (UpdateException ex) { SqlException innerException = ex.InnerException as SqlException; if…
-
11
votes2
answers260
viewsA: Is there any difference between an infinite loop with for and while?
I’ll answer the obvious: it doesn’t change anything, it’s taste. From a performance point of view AP already knows, no matter. But if you want to know if there is a minimum difference, it seems that…
-
11
votes1
answer950
viewsA: Java Interface 8
Abstract classes can contain state and interface cannot. This is the main justification for using it from the more technical point of view. Obviously because it has been, it can have constructs,…
-
12
votes1
answer153
views -
15
votes3
answers823
viewsA: Can I have Javascript write PHP?
Essentially not. And many programmers don’t understand this. They don’t understand what I said in that question. PHP just generates text that by coincidence can be a JS code, PHP doesn’t even know…
-
17
votes1
answer1813
viewsA: What is the difference between Action, Predicate and Func
Func Func is used to determine a delegate. That is to type (create a signature) an anonymous function. It specifies the types of various parameters and the type of the function return. var operacoes…
-
11
votes2
answers2572
viewsA: Main purpose of utility classes
The term can be widely used. As far as I know, there’s nothing very definite about how to use it. Some people say never do this, at least not in the traditional way as they usually do. They usually…
-
5
votes2
answers395
viewsA: Behavior of parameters in the class constructor in C#
The parameters are by value. At least this is the default. But the data type of it influences your behavior. You have types that are by value and types that are by reference. Do not confuse…
-
8
votes3
answers576
viewsA: Session Limitation to Save Data
It doesn’t have a question of being too much for the session, it might be too much for the memory you have available. If you have 600 records in the session, it’s little. If you have 1000…
-
4
votes2
answers4071
views -
13
votes2
answers5548
viewsA: In OOP, can an interface have attributes?
Before we establish the correct term: What is the difference between attribute and field in the classes?. In general, no. But nothing prevents a language from determining that it can. It would…
-
12
votes1
answer2046
viewsA: What is the purpose of the "Return true;" command at the end of a function?
In general you can use somewhere waiting for a function that returns success or failure in the operation, ie a boolean. If the function is used where you don’t need a specific result it doesn’t…
-
3
votes2
answers110
viewsA: Build error when sending to third party check
You can’t start a new Scanner every step in the loop. Then I took your creation out of the loop. I also had the Int instead of converting, I think it looks better, but you can go back to what it was…
-
5
votes1
answer337
viewsA: Site . NET with high performance
Consolidating what is in the comments. Any decision has to go through loading tests and stress or actual use in production. It is no use to assume things. And you will have to redo these tests as…
-
8
votes3
answers3580
viewsA: How to use double and single quotes?
You need to read these two questions (and answers): What is the difference between double quotes and single quotes in Javascript? Difference between single and double quotes in PHP So it’s good to…
-
14
votes4
answers31971
viewsA: Can I write Javascript in PHP?
Javascript as text If your question is whether you can create a text that contains a JS code that will be inserted along with the HTML text you are generating with PHP. Yes, you can. What PHP does…
-
4
votes3
answers4588
viewsA: Algorithm with structure PARA and SE
It can get better, but it works: var nome, sexo: caractere i, m, f : inteiro inicio m <- 0 f <- 0 para i <- 1 ate 56 faca escreva("Digite seu nome: ") leia(nome) escreva("Digite seu sexo…
-
4
votes1
answer213
viewsA: How to improve string comparison and concatenation C#
In performance I can not see anything that can help much, but this kind of thing can only be sure doing tests in real conditions. Unless you’re having real problems, I wouldn’t worry too much about…
-
6
votes1
answer368
viewsA: Error: expected { when creating a class
The most obvious error you are making is to put a list of parameters in a class. Class is not method. Java does not have the Primary constructor (exists in Kotlin and there is proposal for this in…
-
8
votes4
answers1247
viewsA: Function within another
In C# this was not possible (has in C# 7, see more in another question here). Enough to create delegates, but I doubt it’s what you want. As a matter of fact, I see little use for it. Normally this…
-
24
votes1
answer11086
viewsA: How to check the execution time of a method?
You will use the StopWatch(). using static System.Console; using System.Diagnostics; public class Program { public static void Main() { var stopwatch = new Stopwatch(); stopwatch.Start(); Teste();…
-
9
votes5
answers1656
viewsA: Create objects within a list without for/foreach C#
You didn’t use a foreach, and could not even scan this list. Use the Enumerable.Repeat() which is a LINQ method. private List<Compra> CriarCompras(int numComprasParaGerar) { var lstCompras =…
-
8
votes2
answers238
viewsA: How to create operators in C#?
Creating an operator is not possible in the language. So the operator ~ will only exist if the designers and I doubt that this will ever happen. Some existing operators, not all, may have their…
-
3
votes1
answer259
viewsA: Search all methods without reference Visual Studio
In standard Visual Studio there is no way, but there are utilities to install in it that can help. In the Fxcop there are some rules that detect this, especially the Private methods that are not…
-
2
votes1
answer2561
viewsA: How to make an array of objects?
His code doesn’t make any sense. And he’s a little disorganized, which makes it hard to understand what he’s doing. There is a lot of loose things, things do nothing useful. It is difficult to try…
-
2
votes2
answers579
viewsA: How to pass variable normally by value through reference?
I will not look at all your code to see if there are more mistakes. If you gave to understand what you want to do is to pass for reference. Then simply declare the type of the parameter as a…
-
5
votes3
answers3569
viewsA: How to find relationship and cardinality in Mysql?
Cardinality (in this context) is not information found within the database. It’s a concept that we apply in general modeling, to understand how the relationship between the tables is. We usually…
-
11
votes1
answer143
viewsA: What does " " mean in the header of C++?
When you use #define it assumes that the code will have only one line there, unlike normal code, so the preprocessing directives do not end the line with a ;, the line ends when there is a line…