Posts by Maniero • 444,682 points
6,921 posts
-
4
votes2
answers2458
viewsA: What is the purpose of Transactionscope blocks?
Whenever we talk about transactions we are thinking mainly about atomicity, that is, we want a certain block to be executed or nothing to be executed if there is a problem. A common way to solve the…
-
6
votes1
answer185
viewsA: What is Level Trust of an ASP.NET application?
What is the purpose of setting up Level Trust in an ASP.NET application? You determine what the application can and cannot do. Some features can be a little dangerous, especially if it can be…
-
7
votes2
answers651
viewsA: Difference is between Backgroundworker and Task.Run()?
Significant I wouldn’t know how to say it. The mechanisms are very different, but they serve for more or less the same thing, at least if the Task.Run() is used to solve the same problem. Obviously…
-
2
votes1
answer1567
viewsA: strcpy() in struct string
I made a minimal, complete and verifiable example. I didn’t try to make it cute or improve the other code problems, but this one is solved. The team object is being created locally in the function…
-
45
votes3
answers4342
viewsQ: What is the difference between encryption, encryption and hash calculation?
I see a lot of confusion on the site about the terms. In the context of security of data what would be encoding, Encrypting and hashing and in which contexts each should be used? In particular, does…
-
3
votes2
answers306
viewsA: Why do builders have to have the same class name?
Yes, it is. Language requires it by convention. It might not be, but it is so. Documentation. Also. Microsoft documentation. If the specification were published openly I would post here, but the…
-
5
votes1
answer176
viewsA: Error accessing string array
The code has several errors. Strings should be delimited by double and not simple quotes which are reserved only to delimit a character. Is creating a array of strings, but is declaring a array of…
-
3
votes1
answer185
viewsA: Installing Visual Studio 2015 Community with SQL Server
Visual Studio can install SQL Server for you. You can also install separately if you want some other edition that doesn’t come with Visual Studio, which can even only be used for development. SQL…
-
4
votes1
answer2845
viewsA: What is the correct way to declare a struct in C?
Statement of structure struct exem { tipoDeDado variavel; }; It is declaring the data structure, it will have the name exem. It can be used in any part of the application as long as it is available,…
-
6
votes2
answers565
viewsA: What are ASP.NET MVC routes?
I think you want to know about routing as a whole. It is the way to direct incoming HTTP requests to the proper methods of controller. Then as the information comes in this request a different…
-
4
votes2
answers213
viewsA: Treat return in class in C#
It depends on what you call directly in the class. If so, there is no way. But you can do it in the property. public class Mesa { public int Cdmesa { get; set; } public int Flsituacao { get; set; }…
-
2
votes1
answer873
viewsA: How to set basic requirements to run Java desktop application?
Note that there are two chains to specify the minimum. One of them is to use the minimum even, although this almost makes the good use of the application impossible. Another is a minimum that…
-
3
votes2
answers58
viewsA: Visual Studio 2005, can I replace it?
There is some incompatibility, but it is small, certainly will have to make some adaptations, has even converter in it for the project files that have changed (think automatic wheel). Now, a lot of…
visual-studioanswered Maniero 444,682 -
15
votes3
answers1008
viewsA: How is a class organized in memory?
TL;DR In fact the object is only a sequence of bytes equivalent to its fields instance and is totally isolated from the rest. The instance is just the simple object. The rest of what is in the class…
-
11
votes3
answers2010
viewsA: How to optimize the sum of elements in an array
If you want the most performative way: var ar = [1, 3, 5, 8, 2000]; for (var i = 0, total = 0; i < ar.length; total += ar[i++]); console.log(total); I put in the Github for future reference. My…
-
18
votes2
answers319
viewsA: Why are the other types of variables not replaced by Dynamic in C#?
Contrary to what many people think about the dynamic it does not make variables type-less, this keyword only indicates that the compiler should not check their type. C# is a static typing language…
-
5
votes2
answers743
viewsA: Receive by parameter a List of miscellaneous objects
You should use a generic method there to check the type inside. But the ideal would be to make a specialized method for this case (example). I could do something like this: using…
-
4
votes4
answers931
viewsA: How to verify variables that are not used?
Depends on the compiler configuration, but already does it by default. If it is private field the compiler can issue Warning. Especially the CS609 and CS414 warn about unused fields, without and…
-
10
votes6
answers40933
viewsA: Does ternary surgery exist in Python?
In Python the if can be used as much as a statement, as an operator in different contexts. As an operator you can do this: print(1 if True else 2) In his example: x = randint(0,9) print ("par" if x…
-
4
votes2
answers190
viewsA: System modularization
It is very complicated to have a system that works in isolation and at the same time needs to be integrated. It is not easy to make it work properly and only with very detailed information would it…
-
3
votes3
answers216
viewsA: Why is the behavior of the undefined variable different from the undefined property?
Because of the nature of both. The variable is something more concrete in the language, it must exist in the code, has how to verify and know if it exists or not. The property of an object looks…
-
6
votes2
answers1564
viewsA: Is it correct to use the Input tag within a Label tag?
Yes, it is correct if it is what you wish. It is in the HTML 4 specification and in the HTML 5 specification that can put <input> before, after or within the tag/control <label>. Using…
-
1
votes1
answer175
viewsA: What is the increment on a pointer for?
Your understanding is correct, what is being done with y is to change the location it points to, it will point to the next memory address, which will have left junk in memory. In his example the…
-
4
votes2
answers3199
viewsA: What is the convention for using upper and lower case names in Java?
Java has a very simple convention, essentially everything should be camelCase (variables at any location, including attributes, methods, packages). Except type names (class, interface, enumeration)…
-
36
votes2
answers11436
viewsA: What is the difference between Boolean and Boolean?
boolean is a primitive type, that is, it is a number that occupies 1 byte (although it is not specified that it has this size) and is considered a type by value, that is, its value is its own…
-
1
votes2
answers430
viewsA: Problems with a Java Linked List object
I can’t guarantee that the code was actually typed exactly the same. If it was and the intention was to do what is in the question then the booklet is wrong, which does not surprise me where it came…
-
5
votes2
answers240
viewsA: String pointer does not work as expected
There’s a lot of weird stuff in that code, he doesn’t do anything useful, it doesn’t seem like it’s even good for learning. I fixed the problems, but do not want that now is good code to understand…
-
4
votes1
answer356
viewsA: Return modified object
There’s a lot of syntax errors in there, very much just typo. Programming is not playing any text and anyway it will work. I made some modifications and at least compiled. I don’t know if you do…
-
4
votes3
answers3735
viewsA: Generate random number between two numbers with Math.Random
The correct formula would be: ((int)(min + Math.random() * (max - min + 1)) Or if you prefer: Random random = new Random(); return random.nextInt((maximo - minimo) + 1) + minimo; Your code could be…
-
6
votes4
answers364
viewsA: Different methods of creating an object
Generally speaking it’s the same thing. Usuario usuario = new Usuario(); usuario.listar(); Obviously the first is stored in a variable usuario and the object can be used for other things. The method…
-
4
votes1
answer91
viewsA: Is it possible to make a mistake that triggers others?
Yes, it is possible, just relaunch the exception: class Teste { public static void main(String[] args) { func1(); } public static void func1() { try { func2(); } catch (Exception e) {…
-
10
votes2
answers687
viewsA: How do I know if a class implements an interface?
The operator shall be used instanceof: interface Authenticable { // métodos } interface Model { // métodos } class Person implements Authenticable, Model { // métodos } $pessoa = new Person(); if…
-
4
votes2
answers1159
viewsA: Convert string to integer
Since the text comes from a control that the user can type there is no guarantee that the text can be converted to integer, so you have to try to do, if it works out do what you want, otherwise you…
-
4
votes2
answers608
viewsA: How do I know which Arraylist objects are being modified or deleted?
Since you know which object you want just make a copy of it before doing some operation. It is a basic technique, there is no "magic". Altering Pessoa pessoaAlterada = listaDePessoas.get(0).clone();…
-
34
votes3
answers13327
viewsA: What is the difference between vertical and horizontal scaling?
Scaling up The vertical scheduling is to put more memory capacity (main and/or mass) and processing. Ie, is to buy a more powerful hardware to handle. In some cases just create more…
-
6
votes1
answer2052
viewsA: Convert Roman number to decimal
That mistake is on the line: char drSeguinte = numeroRomano.charAt(i + 1); That can solve with: char drSeguinte = i < numeroRomano.length() - 1 ? numeroRomano.charAt(i + 1) : ' '; It has way of…
-
4
votes2
answers1961
viewsA: Practical example List and Arraylist
Just put the object that will be used in the object construction. You can only omit if the variable type declaration is equal to the object construction: import java.util.*; class Main { public…
-
8
votes1
answer93
viewsA: Does Java misjudge memory usage values or is there something wrong with the algorithm?
The task manager is unreliable to see how much memory is being used. In addition it is necessary to understand what each number actually means. Consumption is often a little misleading. There is…
-
8
votes5
answers497
views -
8
votes1
answer273
viewsA: How do I know that the sum of two double’s will be greater than the limit of one double?
The normal is if you exceed the limit of the maximum possible number in the type it turns and start again in the smallest possible number of the type, then the integer would be negative. Unless you…
-
5
votes3
answers428
viewsA: What is the relationship between ERI and relational databases?
DER or Entity-Relationship Diagram, as its name says, is a graphical representation of the entities needed in a data model and their relationships, therefore it is an abstract form. Relational…
-
5
votes2
answers188
viewsA: Is it possible to return a variable from an object-oriented class without using a function?
Yes it is possible: class Square { public int side; public int area; public Square(int side) { this.side = side; area = side * side; } public static void main(String[] args) { Square square = new…
-
2
votes2
answers1356
views -
5
votes4
answers1202
viewsA: What kind of data to use for sale ID
Different data The problem is you’re mixing something internal to the system with something external to the system. It’s even possible to do this, but the application has to work by treating this.…
-
5
votes2
answers808
viewsA: How to save program settings, database or configuration file?
The best for you in this particular situation only you can say. The app.config is used for general settings of how the application works. Normally it should not be used to configure specific…
-
67
votes3
answers10868
viewsQ: What is a racing condition?
What is this such of race condition that can cause problems in applications? How to avoid it?
-
65
votes3
answers10868
viewsA: What is a racing condition?
It is a situation that can occur in all cases where a given computational resource has concurrent (even not apparent) access. The best summary is that the situation needs to count that something is…
-
4
votes5
answers819
viewsA: Is the rest of the code inside Try executed after finding Exception?
I put a complete and verifiable example in ideone. And in the .NET Fiddle. Also put on the Github for future reference. Behold also in the Sharplab. Note that the line of x = 20; has a Warning…
-
3
votes1
answer857
viewsA: Varchar or int for "type" fields
You can’t say without understanding what you really want, without knowing the whole context. I’d say it’s better to wear one int or even a smaller integer type since there are only 6 options. I…
-
1
votes1
answer75
viewsA: Reduce code that refers to the same object?
It doesn’t really work and it doesn’t make any sense. The most you could do is: var objeto = worksheet.Row(1).Style; objeto.Font.FontColor = ClosedXML.Excel.XLColor.White; objeto.Font.Bold = true;…