Posts by Miguel Angelo • 28,526 points
429 posts
-
0
votes1
answer53
viewsA: Logic - Given 2 strings, how to know how many moves I make when turning the first string into the second
An algorithm that does this is Greater Common Subsequence or in English Longest Common Subsequence. The first link, I had to point to a Google search, because I could not find a more immutable…
-
6
votes2
answers455
viewsA: How to fix this error "Cannot Convert from 'int' to 'char[]'
Formatting the output The first argument of the method WriteLine must be a string. This string can contain markers to insert into it, the following arguments: Console.WriteLine("{0} {1} {2}",…
-
6
votes2
answers178
viewsA: How to create events in a for repeat structure?
The problem is that when creating a delegate the captured variable i is the control variable of for, that will be incremented at each iteration. However, the same i will be referenced by all…
-
5
votes2
answers872
viewsA: What are anonymous methods and what is their main purpose?
It is a way to create a delegate as well as lambda expressions. The C# along its evolution has been introducing new ways to create delegates, which practically makes the previous versions unused,…
-
3
votes2
answers51
viewsA: Filtering through empty children
It seems to me that TipoRequerimentoStuacaoAcademica is a collection of TipoDeRequerimento. Try to use !p.TipoRequerimentoStuacaoAcademica.Any() instead of p.TipoRequerimentoStuacaoAcademica ==…
-
2
votes2
answers68
viewsA: Placing sub-items in the CSS3 menu
I think you were almost there. The problem is that you don’t know the levels from the elements. When you follow two selectors using space, CSS selects all subelements at any level. a b {} /*…
css3answered Miguel Angelo 28,526 -
1
votes1
answer180
viewsA: Xmldocument - list all elements?
You can use Xpath to select all nodes: var todosOsNos = x.SelectNodes("//*"); for (int i = 0; i < todosOsNos.Count; i++) { var element = todosOsNos[i]; Console.WriteLine("Elemento: " +…
-
0
votes2
answers626
viewsA: Execute a condition (if/Else) that is inside a string in c# 4.5
If you are on time, and have a desire to learn something cool, you can create a parser of expressions very simple for this. A good recipe to follow in a parser is to create the read methods like…
-
7
votes3
answers2698
viewsA: What are covariance and countervariance?
What’s with the variance talk? I will try to explain the way I have fixed this subject in my mind... in the most intuitive way for me, in the hope that the subject becomes as trivial and easy as…
-
7
votes2
answers179
viewsA: Why can’t I assign a list of a more specific type than the declared type?
What’s the matter with List<Animal> lista = new List<Girafa>() ? It doesn’t work because the generic class List<T> allows inserting into the list. See, I can’t add Camelo to a list…
-
4
votes2
answers1153
viewsA: Hypothesis tests with C# - Merge (sum) of values to find result
If it is possible to sort the elements it is possible to optimize the search of combinations. I will assume that it is possible, and that the elements are ordered in ascending order, as shown in the…
-
7
votes3
answers439
viewsA: How to get a similar behavior between the Garbage Collection of a Single-Page Application and a Multiple-Page Application?
(Note: the OP’s own response is a great alternative, even better I would say. = D Be sure to check!) Refreshes programmed with a Service Worker Gives refresh every 1 hour, and uses a service worker…
javascript memory memory-management single-page-application memory-leaksanswered Miguel Angelo 28,526 -
0
votes1
answer670
viewsA: How to add a Textbox dynamically using VB
Right click on the Combobox and go to: Click New on the screen that appears: I used this code on the sub Dropdown1_Alteração Set oTB = ActiveSheet.OLEObjects.Add(ClassType:="Forms.TextBox.1") Set…
-
1
votes2
answers110
viewsA: Visual Studio C# 2015 does not debug
You can start your application without specifying an instance of Form to the method Run, giving Show in the frm before the Run. Thus: static class Program { [STAThread] static void Main() {…
c#answered Miguel Angelo 28,526 -
3
votes2
answers357
viewsA: Update key in state when another key is updated
About setState How data is stored in state of Carrinho, then the best way to activate a new rendering is by using setState of Carrinho. This new rendering will be done as soon as possible, but not…
-
4
votes1
answer44
viewsA: Is it possible to restrict who can use the public classes of an Assembly?
It is possible to make members internal visible to another specific Assembly using the attribute InternalsVisibleToAttribute. Obviously, you’d have to change public for internal the statements you…
-
7
votes3
answers190
viewsA: Console, Windows Forms or MVC what’s the fastest for heavy loads?
If it is a program completely without interface can create a Windows Forms project, remove the created Form (Form1.cs) and change Program.cs, to look like this: static class Program { static void…
-
7
votes1
answer8384
viewsA: Calculate age from date of birth
We have to consider that age is determined from the difference in years, and if the day of birth is greater than the present day, then subtract a unit: Example: Birth on 10/01/1980 if today is…
-
6
votes1
answer81
viewsA: How to use 'while' on an 'isNaN()'?
It is possible to validate in the event keyup... but I don’t recommend showing a popup, but something more subtle like changing the color of the text. See the example: var tb =…
-
2
votes3
answers287
viewsA: Out Of Memory when running a Getfiles in a very large directory
If the file system of interest is NTFS, there is another way to list these files really much faster: by reading the MFT (Master File Table). There is an answer to this question already in the SOEN,…
-
11
votes2
answers577
viewsA: What is the purpose of unsafe command?
It is not a command but a tag. It serves to instruct the compiler to accept unsafe operations by the programmer. These operations are mainly: pointer manipulation: operator * to obtain the target…
-
5
votes4
answers1698
viewsA: Why use C#extension methods?
One point I haven’t seen anyone address, and a bit more technical, is a type of code-bloating that consumes more memory than desirable. The more a class has defined members, the greater the amount…
-
4
votes2
answers121
viewsA: 2 Datagridview when clicking the first play the record in 2?
For the button to move the records you can do so: var selectedRowCount = dataGridView1.SelectedRows.Count; if (selectedRowCount > 0) for (int i = 0; i < selectedRowCount; i++) { var obj =…
-
1
votes1
answer98
viewsA: Nhibernate is modifying property when returning by Web Api
How well you suspected the culprit is the Proxy of Nhibernate. I don’t think it’s a good idea to serialize the proxy object exactly because you have little control over it. Some options: inform…
-
1
votes1
answer237
viewsA: What to use to connect to the internal-only Web Api
This question is very opinionated and depends on your specific scenario. I’ll try to enumerate some scenarios that might look like yours, but then it depends on you which is the best: if it is…
-
5
votes2
answers650
viewsA: Reference class Syntax Razor C#
A very ad-hoc and strongly typed solution would be use tuples to pass more than one value for the cshtml view: Example - I will pass 2 data to CSHTML (the view model and a string representing the…
-
4
votes1
answer179
viewsA: How to Rank in a List, The Most Accessed Table Link
The algorithm described is quite different from page-rank. It seems to me a matter of implementing a build up with weight in time for each page per user. Each time the user views a page, you go in…
-
2
votes1
answer1153
viewsA: Get information from a div in C#
You can use the Html Agility Pack, which is a library to handle HTML. Nuget: Install-Package Htmlagilitypack You must load the HTML text into the class that handles it, and then you can use XPATH to…
-
2
votes1
answer57
viewsA: What are the differences between these Nuget packages?
JavaScriptEngineSwitcher is a package that allows you to switch implementations of Javascript engines, and each of these packages you have indicated represents one of the possible alternatives to be…
-
3
votes3
answers1923
viewsA: How to fetch a file in all folders
If what you want is to dodge the directories you don’t have permission to, and keep looking in the directories you have permission to, you’ll have to recursively implement the search on your own,…
-
4
votes2
answers405
viewsA: How to use the Maximum Common Divisor (GCD) function in Bigint.js
By the library code, on the same link you passed, you can see that the function GCD expects you to pass two numbers in format bigInt, and non-numeric types of Javascript. To convert Javascript…
javascriptanswered Miguel Angelo 28,526 -
3
votes1
answer72
viewsA: Getting all values on Lambda
You can do several ifs and filter the IEnumerable that at the end will be iterated into a single foreach, it is not necessary to place a foreach for each if: var items = ObjetoE as…
-
6
votes1
answer159
viewsA: Small doubt with numerical operations
From the looks of the operator ** has greater precedence than the unary operator -, that is, first the interpreter calculates the power and then the negative. So the expression -7 ** 2 would be…
-
2
votes2
answers429
viewsA: Run N threads and know when all finished running
It is possible to do this using Parallels (i.e. PLINQ) or Tasks. I recommend using Tasks, as PLINQ will probably eventually become obsolete in favor of the previous. See how to do: using the method…
-
2
votes4
answers3380
viewsA: change class of the clicked element
I made an example using localstorage, which is nothing more than a local key/value warehouse that persists beyond the close of the tab/browser. The only thing I had to do is store the ID of the last…
-
8
votes3
answers2003
viewsA: In PHP the correct is Else if or elseif?
According to the online PHP manual, are considered equal only if used with keys after condition. If they are used with : (without keys), then separate else if will generate an error. On the manual…
-
12
votes2
answers288
viewsA: Sort List<T> using regex
You can build a comparator (IComparer) which compares strings containing numbers, and passes it to the method OrderBy: lista.OrderBy(c => c.Str, meuComparador) This comparator you can do using…
-
3
votes3
answers2029
viewsA: Save to Notepad C#
== Just to complement the answers already given == It is possible to save a file with File.WriteAllText: if (salvou == DialogResult.Ok) { File.WriteAllText( salvar.FileName, textbox1.Text); } So you…
c#answered Miguel Angelo 28,526 -
2
votes2
answers187
viewsA: Doubt about using in Visual Studio
The namespace Windows.UI.Xaml is present for the development of applications for Windows Store, so it was said that only works in Windows 8... there is no Windows Store for Windows 7. If you want to…
-
2
votes2
answers155
viewsA: Iterate a form with JS
It’s just a matter of using jQuery selectors to find the elements. I’ll explain them: td:has(input[type='checkbox']): get all the td who own a input whose type='checkbox' owned by tds, for each of…
-
0
votes1
answer501
viewsA: How to put an image in the popup (on the toolbar part (below))?
On the page that will be loaded, include HTML, on the tag head: if it is PNG: <link rel="icon" href="image.png" type="image/png" /> if it is ICO: <link rel="icon" href="image.ico"…
-
5
votes2
answers1925
viewsA: How to count how many uppercase characters are in a string?
There are several ways to do this: Using LINQ: var str = "Miguel Angelo"; var contagem = str.Count(char.IsUpper); Note: Import LINQ namespace: using System.Linq; Without using LINQ: var str =…
c#answered Miguel Angelo 28,526 -
2
votes4
answers673
viewsA: Large integers and cousins
You can use one of the libraries on this page to solve your problem: http://www-cs-students.stanford.edu/~tjw/jsbn/ -- Translated transcription of a part -- The jsbn library API is very reminiscent…
javascriptanswered Miguel Angelo 28,526 -
1
votes1
answer65
viewsA: Can the Entity Framework not map a table in the MVC occur?
Right click on the Model.tt and find the option Run custom tool:…
-
2
votes4
answers357
viewsA: Objectcache to provide a variable for all users
If you intend your code to be scalable, then the best case is to use a database. Static data into a web application in the memory of the process serving a request is not good practice. Unless you…
-
5
votes3
answers13657
viewsA: How to make a column occupy the rest of the available space?
It is possible to do this with float, simply change the order of the elements in the HTML... the direito should come first and the esquerdo afterward: /* ESTILOS IMPORTANTES PARA A RESPOSTA */…
-
3
votes2
answers1373
viewsA: Shorten the string size
Maybe this is what you’re looking for: Function gzcompress: used to compress a string, returning another string with the compressed content. Function gzuncompress: used to decompress a compressed…
phpanswered Miguel Angelo 28,526 -
6
votes2
answers243
viewsA: Cast problem in a generic method that receives an array of Enum’s (Enum[])
An easy way to solve the problem is to do the box box of item in a object and then give another cast to the final type Enum. A few more suggestions: test the type of T to ensure that this is an Enum…
-
25
votes13
answers20263
viewsA: What makes a language to be considered low/high level?
My opinion is that it has to do with how language resources are made. The lowest level faithfully passes on the machine’s resources (even if it is a virtual machine). While the highest level…
-
4
votes3
answers606
viewsA: Correct Inheritance in Entity Framework
After loading the object cliente comic book you can check the property type. Example using the operator as: using (var context = new Context()) { var cli = context.Clientes.Where(c => c.Id ==…