Posts by Jéf Bueno • 67,331 points
1,254 posts
-
4
votes1
answer127
viewsA: Code Review: Simple MVC
The code presented looks more like a model MVP (Model, View, Presenter) than MVC. Briefly, the main difference between the two standards is that in MVC there is a controller that decides which view…
-
2
votes3
answers900
viewsA: how to find a string for json
With the JSON.NET library it is possible to create an instance of the class JValue from the string and then show the representation of this object in string again using formatting option that…
-
2
votes1
answer278
viewsA: How do I extract the name of multiple folders within a directory?
You can use the function listdir. This function will return all files and all directories inside the specified directory. To check if the item is a directory, you can use the function isdir. Note…
-
5
votes1
answer156
viewsA: Why use readonly to instantiate?
The readonly is just an access modifier like everyone else. It has no magic. This access modifier applies to fields created in a class. When using it, the field can only have a value assigned to it…
-
4
votes3
answers475
viewsA: Reverse SQL ordering
Yeah, just use the reserved word desc. Select Coluna From Tabela Order By Coluna Desc;
-
6
votes2
answers1328
viewsA: Vectors names and ages - Python
The code could be written in a slightly better way, to avoid some problems, such as when two people are the same age. But if you don’t want to run over things and end up getting lost in your…
-
1
votes2
answers139
viewsA: Javascript function does not work
It’s probably because you wrote for wrong. Do for (var i in objs) will iterate through all properties of objs (including the indices) and each variable loop i will be one of these ites. You are…
javascriptanswered Jéf Bueno 67,331 -
2
votes2
answers93
views -
3
votes1
answer96
viewsA: How do I display all the columns of my BD Asp.net mvc
This happens because you create a list for each loop and try to return this list still inside the loop. This will cause the flow to end still in the first loop while. The correct thing would be to…
-
6
votes1
answer181
viewsA: Function to return the proper python source code name
Just use __file__. For example: print(__file__) It is also possible to import the module sys and get through it the first argument of execution, which is always the file name. For example: import…
-
2
votes2
answers589
viewsA: How to list only the name of existing folders in a given directory
It is possible, using LINQ, to map each complete path to an instance of DirectoryInfo and, from this instance, get only the "final name" of the directory using the property Name. var source =…
-
1
votes1
answer95
viewsA: How to inherit a form in c#?
As the error says, the binary type Form are not referenced in the project containing the class ControlFuncionario. Add to this project a reference to Assembly System.Windows.Forms.…
-
5
votes3
answers5118
viewsA: Java Tabulated Calculation, using Repeat Loops
You only need one variable to represent the multiplier of the input value and control the value of this variable within the loop. import java.io.IOException; import java.util.Scanner; class Main {…
-
5
votes1
answer478
viewsA: Converting Java code to C#
The only thing that changes is that the method to convert a string for a 64-bit integer is the Convert.ToInt64 instead of Long.parseLong. Note also that the code writing convention C# says that the…
-
3
votes1
answer242
viewsA: What is the difference between Xmldocument and Xelement?
XmlDocument represents an entire XML document. It is possible to use this class to manipulate XML files. XElement is a class of System.Xml.Linq, it is used to represent a single element within an…
-
5
votes2
answers824
viewsA: What are the variations of ASP.NET?
ASP.NET Initially it was what we call Webforms today. Webforms was used a lot, but it has already fallen into disuse and, apparently, fell into the disgust of the staff. I can’t say in detail, but…
-
2
votes1
answer29
viewsA: Set array type property size
That is not possible. How you intend this property to be "arrow" by the consumer of the code, the best alternative would be to validate in the method set of property using System; public class…
-
3
votes1
answer348
viewsQ: How to print the binary representation of a character?
I am in need of obtaining binary representation of the characters of a string. I can do the hexadecimal representation with own printf using %x. Something like: void imprime_hex(char *input) {…
-
4
votes3
answers2496
viewsA: How do I find the C# version I’m using?
Click the project file (usually a csproj) with the right button Properties Build Advanced In the section general has language version…
-
3
votes2
answers52
viewsA: Error when trying to use class/method of a library.
This class is not available in version 1.5.0. That, according to this previous question, is the version you have referenced. In the section Assembly, in the class documentation you can check…
-
5
votes1
answer590
viewsA: How to apply 2 mascara to the same textbox windows form c#
Semantically speaking, it would be correct to use radio button in place of checkboxes, since the user can only mark one of the options. Anyway, the implementation is exactly the same: In the event…
-
3
votes1
answer36
viewsA: Doubt in the storage of variables
The code of MessageBox does not make sense. There are no variables Nome, Tel and End. The variables are nomeDigitado, telDigitado and endDigitado. The code should be MessageBox.Show("Cadastro de " +…
-
1
votes3
answers578
viewsA: How to put two action with HTTPPOST
See what the error says (highlight made by me): The Current request for action 'Index' on controller type 'Homecontroller' is ambiguous between the following action methods:…
-
2
votes2
answers360
viewsA: How to sync git between two machines?
To clone the repository git clone enderecoRepoOnline To update git pull
-
0
votes1
answer192
viewsA: How to use Enum with Entityframework
Not possible. In Entity Framework types by value cannot represent a table.
-
1
votes1
answer1225
viewsA: Polymorphism with interface and abstract class
First you need to think about the way you’re working, it seems wrong to me. I don’t have to give a lot of improvement tips without knowing more about the context, but it would be a good start…
-
2
votes2
answers116
viewsA: Is there any way to simplify this amount of conditions?
It doesn’t have much to garnish. You can replace those if’s chained by a for. BTW, the three if’s being chained doesn’t make much sense because they write in the same place, ie, one overwrites the…
-
1
votes1
answer2080
viewsA: How to change line in text file in C#?
Yes. You can simply read the entire file using the method File.ReadAllLines(), change the line and then write to the file using the method File.WriteAllLines(). var arquivo =…
-
3
votes2
answers77
viewsA: Selectlistitem with custom attributes
You need to keep in mind that not everything can or should be written using HTML Helpers, they serve to make things easier, but in cases where you need more freedom you better choose not to use…
-
3
votes1
answer568
viewsA: Psqlexception: No results returned by query
Note this line of code rs1.next(); The method next of ResultSet serves to move the "cursor" to the next line returned by the bank. As a insert does not return anything, it is popping this error.…
-
2
votes1
answer352
viewsA: Error trying to insert data to Postgresql
The syntax of insert is incorrect. Error tells exactly which part is wrong. ERROR: syntax error at or near "set" It’s like this st1 = conn.prepareStatement("insert into pessoa set (...) values…
-
1
votes1
answer1815
viewsA: A view using two MVC models
Just create a ViewModel with both models public class DetalheProjetoViewModel { public ProjetoModel Projeto { get; set; } public DetalhePrjModel Detalhe { get; set; } } and then change in the view…
-
2
votes1
answer1150
viewsA: Turn Httpresponsemessage return to JSON
StatusCode and ReasonPhrase are part of the answer header. If you want this to be part of the body you will have to concatenate the values into Content or personalize the response. Maybe you should…
-
9
votes1
answer434
viewsA: How to create a random number of 5 digits starting from 1?
The problem there is that you need to format the account number with zeros on the left to fill in the number of boxes you describe. One of the ways to do this is by using the method String.format,…
-
2
votes2
answers266
viewsA: How to use Distinct() or Groupby() in a list that returns an anonymous type?
If you want to make a distinct by property NavioId, you can group the results by this property and then use the method Distinct. Usually I prefer to do an extension method for this public static…
-
2
votes2
answers138
viewsA: Popular class with json
You need to notice that actually, DadosIndicador is a string. You need: fix the JSON; or customize the deserializer; or use the property as string; or deserialize it separately. Here’s an example of…
-
2
votes2
answers46
viewsA: How to have access to Label again in Visual Studio
Has a window called Document Outline, on it will be all the form controls and when you click one, it will be selected in the form designer. I will put an image as soon as my computer collaborate and…
-
2
votes1
answer1329
viewsA: JAVA standard deviation
The error is in the calculation of the standard deviation at the end of the method getDesvioPadrao. In it you return the square root of the variance division by the collection size. How are you…
-
2
votes1
answer40
viewsA: Get parameter by url for my controller
Put the parameter of action with the same name as defined in the route. public class CheckController : Controller { public ActionResult Indice(long id) // <- trocar o nome do parâmetro {…
-
3
votes1
answer53
viewsA: How to inhibit textbox but display ID data
Changing the property Enabled for false, or the property ReadOnly for true. In most components, change the value of ReadOnly keeps the control with the same appearance, but prevents some value from…
-
2
votes1
answer139
viewsA: Identify two pressed modifier keys
The guy Keys is a mask of bits (a combination of bits) This way, you can use binary operations to check if more than one modifier is pressed if (Control.ModifierKeys == (Keys.Control | Keys.Shift))…
-
2
votes1
answer37
viewsA: Does not list database data correctly in View Asp.net
First of all, don’t sort the data in memory unless you have a reason for it. Of course this is not a recipe that you should follow blindly, but most of the time delegating ordering to the database…
-
2
votes1
answer446
viewsA: How to know if foreach is going through the last item on the list
You probably need something better, but there’s no way to know without further details in the question. What you ask is this void Main() { var lista = new List<int>() { 2, 6, 1, 4, 20, 21};…
-
1
votes1
answer1906
viewsA: Error: The model item passed into the Dictionary is of type X but this Dictionary requires a model item of type Y
See, the mistake says the guys aren’t the same. All you need to do now is get them to agree Create a new class, I’ll call it ViewModel because I can’t identify the nomenclature pattern you’re using…
-
8
votes2
answers2261
viewsA: I need to do a SUM inside Group BY in Lambda
The method GroupBy returns a grouping structure. This structure contains all the data of the grouping in question and also the key (Key) from it - this key is the one responsible for the grouping.…
-
1
votes1
answer201
viewsA: How to work with arrays at Angular 5
Use the function map pesquisarEstados() { this.cidadesService.listarTodosEstados().subscribe(dados => { this.estados = dados; console.log(this.estados.map(() => <any>e.codigo)); }); }…
-
2
votes1
answer89
viewsA: Error when placing SUM
It’s because the query doesn’t make sense, first you’re adding up and then trying to group. Keep in mind, first, that the Sum returns a integer. Therefore, it makes no sense to try to apply a…
-
4
votes1
answer2980
viewsA: C# Console Application. Read Json File
The estate map is a list of lists. Besides, start is an object and not a string, this also needs to be corrected. public class Inicial { public IList<IList<string>> map { get; set; } //…
-
10
votes2
answers1752
viewsA: Is it possible to evaluate a ternary expression with 3 possible values?
No. The ternary operator only works with two expressions. The most you can do is something similar to the code below, nesting the ternaries. Keep in mind that this makes code extremely difficult to…
-
1
votes1
answer778
viewsA: Insert key function - Visual Studio Code
This does not exist by default in VS Code. I don’t know why, since it is something extremely common. You can see about this in this Issue on VS Code’s Github. One of the things that can be done is…
visual-studio-codeanswered Jéf Bueno 67,331