Tagged Questions
C# is a multi-paradigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform.
0
votes
0answers
13 views
A queue with access to the last element
Following this question, I realized there is no built-in data structure like that, so I implement my own queue using List<T>.
Please comment on performance ...
1
vote
1answer
24 views
Improving performance on file reading
I got a small assignment to read IP adresses and from a bunch of external text files identify which country the IP adress comes from.. I opted to use XmlReader and read the ranges from an XML file but ...
1
vote
1answer
25 views
2
votes
0answers
17 views
Isolate class to be instantiated only by a specific class: best practices
Ok, I am working with 2 layers of class: somekind of a "manager" class which task is to take an object, link all items attached to it, and return it to the caller, and a "data" class which task is to ...
-2
votes
1answer
22 views
Suggestion for refactor wpf project
I have done a WPF project and hope everyone can give suggestion for code refactor, especially for
UpdateErrorList() method within the MainWindowViewModel.cs
...
2
votes
0answers
20 views
Inspector interface serializer
I've written some code that allows Unity3D's inspector to display fields that conform to an interface. Unity has some quirks about their inspector, so as a preface they are listed here:
If you add a ...
4
votes
1answer
43 views
Breadth First Search not SOLID enough v2.0
Here is a link to my original question:
Breadth First Search not SOLID enough
Here is my first attempt at refactoring. Instead of using a Tuple, I used a ...
2
votes
2answers
674 views
Unsafe Stack in C#
I was interested to see if it was possible to implement an unsafe stack in C#, so I wrote this:
...
3
votes
2answers
95 views
Miller-Rabin Recursive Primality Test
I'm working on a primality test and have written a recursive function that returns the value of the function
\$b^{q-1} \bmod q\$
where \$3<= q <= 32000\$
Is there any way to speed up ...
2
votes
0answers
40 views
Unity Dependency Injection
This is my first time using Unity so bear with me for a moment. I have a sample Visual Studio 2012 solution with 4 projects (but only two of these projects will be used with Unity). This is the ...
7
votes
1answer
126 views
Breadth First Search not SOLID enough
The following code has a modified version of the Breadth First Search algorithm. It not only visits the nodes, but keeps track of the paths, so I can output various messages later. I would like to ...
8
votes
4answers
1k views
6
votes
3answers
547 views
String compression implementation in C#
I wrote a method that reduces a string like aabcccccaaa to a2b1c5a3
My implementation:
...
3
votes
2answers
82 views
Implementing faster StringBuilder that only works with ASCII strings
I wrote a StringBuilder that works only with ASCII strings. the current append performance is almost identical to BCL StringBuilder append performance. I want some tips on how to make it faster, and ...
1
vote
2answers
48 views
Queue with task parallel library
I am new to programming using the .Net TPL Framework and multi-threading in general. I have googled up some tutorials and articles and put together the solution below.
It is a simple multithreaded ...
5
votes
5answers
740 views
Is this queue properly implemented?
I tried to implement a queue which stores it's elements in a resizing array. Seems to work fine. Can you tell me if i did something wrong?
...
2
votes
0answers
47 views
Supporting Enum in EF 5 with .Net 4.0 (Visual Studio 2010)
I'm currently working through Getting Started with EF5 using MVC 4 in Visual Studio 2010 (.NET 4.0) to learn about how to use ASP.NET and Entity Framework. During the beginning of the tutorial I ran ...
0
votes
2answers
88 views
Request Response pattern in C#
I have created a C# library that can send commands to a device and process the command specific responses and broadcasts over a serial port (or other communications method).
The library must also be ...
4
votes
1answer
380 views
Maximizing XOR HackerRank challenge
I know that there are combinatoric libraries for this kind of thing. However, with me being new to C# and coding in general I found that I couldn't understand the code well enough to implement it in ...
3
votes
2answers
481 views
Exception handling best practices
I'm actually working on a piece of code which use the following code:
...
-3
votes
0answers
66 views
a console program that calculate a math equation input: example 5-2*3/3 [on hold]
When run with the equation in the title, the below stated program returns 15,6666666666,
mathematically 3 is the correct solution.
What's wrong in the code?
...
2
votes
1answer
39 views
4
votes
2answers
52 views
Secure password hashing implementation
I'm implementing a password hashing method for a website. The code below is part of the User class.
Any pointers on what I could do better?
...
2
votes
2answers
97 views
Improving the performance of Linq based solution
Again, out of fun on saturday night, I decided to solve the following problem from CodeEval.
The challenge is finding the index of the lowest unique number.
...
1
vote
2answers
97 views
Project Euler #3 solution
I'm trying to solve Project Euler problem #3, which asks:
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
Can you please review ...
-2
votes
0answers
42 views
console program that calculates user math equation input from the list like: 1+7-2/3*4 the return answer [on hold]
i want to create a c# console calculator that calculate a user's input/ equation from the list and return the answer.
...
3
votes
2answers
47 views
Calculation of RGB values given min and max values
I made a start at translating the accepted answer's code here into C#. Any suggestions on the correctness of the translation and the correctness of the original code would be very much appreciated.
...
6
votes
1answer
50 views
Logging auditing information
I had to implement an auditing system where the user have to provide a reason he needs to perform a certain operation. When he provides the reason, he can perform freely it for a certain amount of ...
4
votes
2answers
127 views
Is it “legit” to use a Linq query in a razor view?
I have a Linq query in my razor view like below. Its just getting contacts that belong in the group.
...
3
votes
3answers
63 views
Implementing a POC Async Web Crawler
I've created a small proof of concept web crawler to learn more about asynchrony in .NET.
Currently when run it crawls stack overflow with a fixed number of current requests (workers).
I was ...
-2
votes
1answer
52 views
How to make this xml query shorter [on hold]
I spent 3 days to read this xml file and put the details in to the database. It works the way it should be but I know the way i read this xml file is not the proper way.
Can you please show me how to ...
2
votes
1answer
47 views
Insert missing records in a list with LINQ
We have a table with periods, and other child tables with these periods and values for combinations of product + location.
Based on selected periods, I would like to add any missing rows in the child ...
2
votes
0answers
48 views
Using readonly input fields to persist data between views
I'm building a multi-screen Ajax form in an ASP.NET MVC solution. The first screen displays some user details. If the user clicks 'edit', they are taken to the next screen where they can edit the ...
5
votes
0answers
69 views
+100
Understanding the MVVM concepts and validation of my code
I have been learning MVVM concepts and trying to implement it in my new project. I want to validate my work that I have been doing these past days. I want to know if I follow correctly the MVVM ...
3
votes
2answers
157 views
Fastest way to find and replace inside a large amount of files
Currently I am looping through dependencies of objects, and I am trying to replace GUID (unity object ID's) inside the files.
Right now I am using the following code, any suggestions for improvement ...
1
vote
4answers
308 views
Creating a grid in HTML from a database search
I have a little piece of code that is a little bit unoptimized and need some help with optimization in this case.
The procedure is to search in a database using "Conditions/Condicao" and create a ...
4
votes
1answer
55 views
+50
Concurrent Task Waiter 2
This is an iteration of my previous question: Concurrent Task Waiter
Summary from before:
I have some code designed to simplify managing multiple asynchronous
operations. The code creates ...
3
votes
1answer
92 views
Big switch statement for sorting a table
I have a webpage with a table. The table, with 10 columns, can be sorted by each column ascending or descending.
At this moment I control order by big switch:
...
2
votes
1answer
26 views
Reporting progress to main form's controls from within a threaded heavy task
I'm trying to figure out how to nicely write a Winforms app that reports the progress of completing a long task onto the main form's controls without causing Cross-thread op exceptions and such. So ...
3
votes
1answer
42 views
Immutable Matrix
I'm writing implementations of some numerical methods to solve linear equations systems, those implementations use the following Matrix class. I'm trying to get this class immutable, due to that the ...
3
votes
1answer
64 views
Efficiency of nested LINQ foreach loops
I've been working on an older project with framework is 3.5 as the target. There is a new user control that displays a list of data from a web service. I hit the web service (Soap/XML) and deserialize ...
2
votes
1answer
35 views
Implementing ViewModel design pattern using DI in a MVP-VM architecture
Based on this answer: MVVM implementation using C# and XAML, I understand that my ViewModel is some kind of a wrapper for my Model.
Being a fan of DI and SOLID principles, I have made my ViewModel ...
19
votes
3answers
2k views
Proof that I was wrong about Random Number Generators
I wrote this code to show how wrong I was about Random Number Generators.
Context:
From Comments to this answer to Regularity in the "Rusty Towel of Mutual understanding"
that isn't ...
5
votes
2answers
87 views
C++ application calling C# Dll marshalling strings
The code appears to work fine. The values are returned as expected from the DLL and the values are added correctly to the DLL.
Will the way I am passing the string to C# cause a memory leak?
Also, ...
4
votes
2answers
47 views
Determining if a discount is valid for a product
I'm in the process of re-writing a method I've come across in our code base. It's pretty lengthy and a lot of it seemed redundant. It's a Discount object class ...
1
vote
1answer
44 views
Concurrent Task Waiter
I have some code designed to simplify managing multiple asynchronous operations. The code creates callback actions that, when executed by the asynchronous operation, track which asynchronous methods ...
3
votes
2answers
45 views
8
votes
5answers
837 views
Singleton Database class
Currently my team is building an application involving a database. We have to write a lot of data (approx 2,000,000 records) to the database and therefore we decided to open a connection once and ...
7
votes
3answers
273 views
Indentation on a long (ish) linq chain
I have some code that loops through directories named for years (e.g. /2011/, /2012/ etc) which each contain files whose names ...
4
votes
1answer
90 views
Avoid while(true) in task scheduling code
I am writing a task scheduler (that will one day grow up to be a windows service when I look into them) that should pretty much loop infinitely until I tell the program to stop. But having ...