Posts by Jéf Bueno • 67,331 points
1,254 posts
-
1
votes1
answer50
viewsA: Can you convert an array of strings to a double array without concatenating the decimal numbers in the conversion?
The Convert.ToDouble considers the culture, as you did not inform a culture as a parameter will be used the one configured globally (in the operating system or some global configuration for the…
-
1
votes1
answer37
viewsA: Cast from Object for an object created in Typescript
I don’t usually program in Typescript, but one of the things you can do is check if a certain property exists inside the object you’re receiving. For example: constructor (config: object) { if ("id"…
-
0
votes1
answer41
viewsA: How to filter a List record within another list c#
As you are using EF Core 5, you can make a Include with filter. See more in this post about the news of EF Core 5. var apps = _dbContext.Set<App>() .Include(a => a.Comentarios.Where(c =>…
-
0
votes1
answer37
viewsA: Post a preset phrase on Twitter
I don’t know if it makes sense what you want to do, but it is possible to pass the parameter text to the URL you are using. <a href="https://twitter.com/compose/tweet?text=Olá Mundo"…
-
3
votes2
answers84
viewsA: How to return the last character of a String in C++?
You can use the method std::string::back(). Read more about it in the documentation link. Note that C++ does not have the same Python syntax, so its code does not work. #include <iostream>…
-
1
votes1
answer23
viewsA: Repeat process upon receiving invalid entry
The problem is that your code is poorly structured. First the condition of the while seems reversed if your intention is to repeat something while the entry is invalid. Second, while does nothing,…
-
1
votes1
answer40
viewsA: Sending File to API with Authorization . Net 5
Missing pass token for requisition. Since the HTTP client is only used within this method, you can do so: client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer",…
-
9
votes1
answer93
viewsA: C# init equals private set?
The behaviors of the two access modifiers are quite different. The fact that it is not possible to change the value of the property outside the class is the only similarity. In fact, the properties…
-
2
votes1
answer33
viewsA: How to receive querystring value in an action?
It is possible to declare a parameter in the action and use the attribute FromQuery. public async Task<ActionResult<AppResponse>> GetAsync(Guid id, [FromQuery] string nome) { var app =…
-
2
votes1
answer30
viewsA: After passing a class by interface reference, how to recover your Type?
Yes, it’s possible and it’s very quiet. You can define whether an object is of a certain type using the operators is and as. If you are using new versions of C# (7 or higher), you can use Pattern…
-
6
votes3
answers142
viewsA: Multiple cases on switch with C# 8
It is not possible to make two patterns fall in the same case. Note that the switch expression is different from statement (statement) switch. The simplest way to achieve what you want is to create…
-
0
votes1
answer64
viewsA: How to select specific files in a folder?
It’s quite simple. You can simply get all the files from "pastateste" and apply to the returned collection a filter using the Where linq. In the example below is done the file filter using a regex…
-
4
votes1
answer75
viewsA: Reversing the commit
If you want to keep the last commit changes (they stayed in the Stage) git reset --soft HEAD^ If you prefer to discard them git reset --hard HEAD^ You can also tell the commit hash you want to point…
-
0
votes1
answer37
views -
3
votes1
answer32
viewsA: Find the year in which total customers (sum) was higher
The first select is correct according to the result example you put in the question. If the table name is really table (by the way, the name is terrible) you should escape the name using backticks…
-
2
votes2
answers181
viewsA: Can I have multiple thead and tbody inside a single table in HTML5?
Syntactically it is likely that anything is possible, but semantically zero or one is allowed thead and zero or several tbody. console.log(document.querySelectorAll("table tbody").length) table {…
-
2
votes1
answer108
viewsA: How to pass a string as a parameter in Action
You need to define where this value comes from. In case of a GET request, it may come from the route: [HttpGet("{hosts}"), ActionName("Search")] public async Task<IActionResult>…
-
0
votes1
answer33
viewsA: How to place the Icon at the end of an H4
You can solve this easily with CSS using flex. .container { width: 100%; display: flex; /* Define que o display dentro do container será flex */ flex-direction: row; /* Define que os elementos…
-
7
votes1
answer113
viewsQ: Is there a difference between using discard or ignoring the value returned by a method?
I have a method similar to the below: public bool FazerAlgoERetornarSeSucesso() => true; And at some point, I need to call this method, but I don’t care about the result. Normally I would do…
-
0
votes1
answer30
viewsA: How to return a file to the client?
Instead of trying to salvage a file, you need to return that file to the caller of your action. This can be done using the method File(). I don’t quite understand this manipulation you made before…
-
2
votes1
answer33
viewsA: Value insertion problem in an array/list
Overall, your logic doesn’t make much sense. You need to create a list to store the numbers and instead are trying to access indexes in a variable of type Int. You need, basically, this: import…
-
1
votes1
answer30
viewsA: How to read a 'Boolean' column using NPGSQL?
If the field in PG really is a boolean, use Convert.ToBoolean checkBox1.Checked = Convert.ToBoolean(dr["inativo"]);
-
2
votes2
answers95
viewsA: String inside Python list
The problem is that you’re creating a tuple at the moment you do quantidade = EAN, quantidade However, you are comparing it to a list of lists. That is, each element in your list is another list…
-
0
votes2
answers241
viewsA: I cannot change font size in C# (Property or indexer 'Font.Size' cannot be Assigned to -- it is read only)
You will need to build another object Font. Also, you cannot change the property DefaultFont of some control, this is a static property used to fallback. In this case, it is necessary to change the…
-
2
votes2
answers256
viewsA: Adding a value to an object array with reduce
Thus: array.reduce((a, b) => a + b.points, 0) Basically, what happens is that the function you pass by parameter to the reduce (a + b.points) will be executed for each item of the array. The…
-
3
votes2
answers45
viewsA: How to split a string in Mysql?
You can use the function SUBSTRING_INDEX. The first parameter is the value you want to divide, the second is by which character the string will be divided and the third is which of the cut values…
-
0
votes1
answer194
viewsA: C# Double Type Precision Loss
This happens because of this adjustment of replacing the comma by point. The question code does not consider the application culture and this can be a big problem (just like now). What happens there…
-
0
votes1
answer62
viewsA: Error searching for record with Firstordefaultasync ASP . NET CORE 3.0
See, you’re firing a request like this: this.http.post(this.rootURL + '/search', this.cpf) A piece of the URL is missing: this.http.post(this.rootURL + '/cliente/search', this.cpf)…
-
1
votes1
answer250
viewsA: Search log by Cpf ASP . NET CORE 3.0
The Find (and its asynchronous version) only search for primary keys. To search for other fields, you need to use other methods. In this case, you can use the method FirstOrDefaultAsync await…
-
5
votes2
answers181
viewsA: Simple ways to break a *while* with a function
I don’t understand why you don’t want to do the break in the while. That’s where he belongs, there’s no point in leaving him in another role. What you can do is model the code a little differently.…
-
1
votes1
answer49
viewsA: Check for element in array
You’re comparing the whole set using names == "Pedro". You should only use one element names[i]. See below working: let names = ["Ana","João","Pedro","Maria"] console.log(hasName()) function…
javascriptanswered Jéf Bueno 67,331 -
1
votes1
answer31
viewsA: Apply filter to a list returned by a mock
This happens because the method you mock has no logic, it simply returns a list. You should do something like this: mocker.GetMock<IUsuarioRepository>() .Setup(c =>…
-
2
votes1
answer151
viewsA: How to pass a url variable in web api that contains / or a question mark?
? and / are characters reserved in a URL. You will need to encoding these characters: ? stays %3F and / stays %2F. Note that if your parameter should be in the query string, you are setting the…
-
0
votes1
answer137
viewsA: Check if the selected line is the penultimate of datagridview
dgvDados.CurrentRow.Index returns the current row index. dgvDados.Rows.Count returns the number of rows in the grid. That is to say, dgvDados.Rows.Count - 1 is the index of the last line, so,…
-
1
votes2
answers80
viewsA: C# - Loop no while
The problem is that the expression LINQ does not make sense. You are consulting items that exist in a directory and then using the Exists to validate if the item exists (but the query has already…
-
0
votes1
answer39
viewsA: Inserting data with a proc in SQL Server
What happens is that the first insertion occurs successfully. However, in the second, an error occurs because the value of @codprod is NULL. This is caused by the place where the @@IDENTITY. This…
-
1
votes1
answer960
viewsA: Error The type or namespace name 'Model' could not be found
That’s because probably the FuncionarioModel is in a namespace different - I inferred this because it is normal to organize the namespaces in project folders . NET. In this case, or do you care…
-
3
votes3
answers61
viewsA: How to specify the files I want to add to the Stage area?
The . (point) in git add (in GIT versions 2.x) says you want to add in Stage all modifications that were made (all new files, all modified files and everything that was deleted). Specify the files…
-
2
votes2
answers35
viewsA: Why is the return 115?
Because the return of printf is the amount of characters written, you can check this in documentation. The problem with your code is that it does two prints: that of the printf and that of echo. You…
-
2
votes1
answer40
viewsA: Show user-selected date using Monthcalendar
If you’re wearing one MonthCalendar, could do the following: private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e) { var data =…
-
2
votes2
answers75
viewsA: Get specific value in a txt file
As Maniero said, "If the information is this take the given by the position he is in". That is, by the example you have published, it is not necessary to use a regex. using System; using static…
-
1
votes1
answer54
viewsA: I can’t create a user in Mongo from Docker
The command should be docker exec -it ...
-
1
votes2
answers79
viewsA: When selecting a certain value in the combobox, insert values in another
There is no way of knowing what mistake you are making. The question does not show enough details for this. So I’m going to show you a minimal and complete working example. In the Load of the Form I…
-
3
votes2
answers2067
viewsA: Merge two lists c#
It is possible to do using the method Concat linq. var listaConcatenada = lista1.Concat(lista2); See working on Repl.it…
-
2
votes1
answer900
viewsA: Error: No support for keyword: 'Provider'
Just take this one Provider connection string... connectionString="Server=SRVSQLDEALER\VDLSQLDB; User ID=monitor; Password=monitor; Database=dbRentabilidade_teste;Persist Security Info=True;"…
-
2
votes2
answers122
viewsA: When should I use generalization in case of use?
Generalization in use cases is analogous to generalization in databases or object orientation (which we call inheritance). When speaking of actors, several actors can play the same role in a…
-
0
votes2
answers129
viewsA: I can’t call CSS
Exchange the EditorFor for TextBoxFor and the third parameter needs to be a direct object with HTML attributes, not with this property htmlAttributes @Html.TextBoxFor(model =>…
-
1
votes1
answer74
viewsA: Doubt POO Javascript
You need to keep in mind that in Javascript some things are different from most languages that work with OO. Properties are defined members directly on the objects and not in the classes as it would…
-
1
votes1
answer24
viewsA: Form does not respect Location set manually
Missing "warn" that you are setting the position manually. aviso.StartPosition = FormStartPosition.Manual;
-
3
votes1
answer62
viewsA: How to create extension methods in Kotlin
Yes, there is a feature very similar to C#. You just need to prefix the function name with the type that will receive the extension method. You can see more about this on documentation. fun…