C# is a multi-paradigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform.
0
votes
0answers
30 views
Why is loading images taking so long?
When Page_Load is executed I assign the ImageUrl which is a IHTTPHandler:
...
2
votes
0answers
27 views
Game stats storage / display
I have a simple game where you try to go as high up with rockets as possible. I currently store 2 statistics about your playthrough:
Current altitude
Highest altitude
These statistics are stored ...
0
votes
3answers
47 views
Using for loop to fill 20 picturebox number 'i' with image
I implemented that as follow and it works (i got the solution here : C#: using for loop to fill picturebox number 'i' with image)
, but I really wonder if i can do that without having to ...
2
votes
1answer
40 views
Prefer simplicity over testability? [on hold]
Currently I try to create some unit tests for a project, which provides access to some webservice methods.
It's interface is rather simple. I have a class "WebService" which offers methods like ...
2
votes
1answer
33 views
Is this the correct usage of ConcurrentDictionary<TKey, TValue>?
I need to make a simple class that tracks how many clients are listening to a specific item, will be referred to as building hence forth. I will have a timer running that will check which buildings ...
1
vote
1answer
50 views
Is there a better design pattern for a SDK?
At work I decided it would be better to reverse engineer a SDK for one of our pieces of hardware. Because it is work related I can't share the exact code.. but I can give enough of a gist of the code ...
2
votes
1answer
56 views
Null checks in view
It's really a nitty-gritty issue for me, and I have been here many times before. How could this be improved?
I have a basic viewmodel for a view:
...
1
vote
0answers
25 views
4
votes
2answers
77 views
Check if any of class properties is not null/empty/was assigned
I have a class that I use to display on a web page fieldset. However, all of the properties of this class are optionally filled in by the user, which means all of them could be null/default. In this ...
5
votes
2answers
92 views
Time Sensitive ConcurrentDictionary
In our application, we have many function calls that we want to cache the results of. However, the result of these functions depends on database calls, so we want this cache to refresh every so often ...
2
votes
2answers
55 views
Transliterating Tatar To Cyrillic
Input :
<h2>{translate} Dear Atteck {/translate} <br/></h2>{translate}Please complete registration</h5> {/translate}
Output :
...
0
votes
1answer
42 views
Use parent class to declare a child object or how compiler allocates memory
I'm working with C# and .NET Framework 4.0 and Windows Forms.
On my project I have three custom objects that inherits from MyControl class (...
1
vote
2answers
59 views
ComplexProperties with Reflections
I have used reflection for divide the complex property. For example, if I bind A.B[0], CustomerName means CustomerName is returned. Can anyone help to reduce the ...
0
votes
0answers
36 views
Console Application Customizer - GetBootstrap v2.0
GetBootstrap-2.0 update from GetBootstrap-1.0.0.2
I just update my console application customizer and add some new features like disable minimize, maximize and close button, new color and simple ...
3
votes
2answers
126 views
3
votes
2answers
174 views
Get missing sequential numbers from array
I have an array like Original = {1, 2, 3, 6, 7, 8, 9, 10, 12}. After removing some elements like Delete = {6, 7} from it, I want ...
5
votes
2answers
100 views
C# program that uses events
I am trying to learn C#. Please tell me if the following code respects coding standards and naming conventions because I want to write beautiful code. The purpose of this program was to help me ...
-4
votes
0answers
17 views
how to Search text in PDF,excel and word documents if content available in file show file link and bind in grid(C# sample) [on hold]
I have a folder with a lot of PDF,excel and word files. I would like to develop an ASP.net application that enables the user to search by text in available inside pdf,excel and word and bind file in ...
-1
votes
2answers
60 views
Sorting array with respect to two properties
I'm sorting with respect to Width and Length. However, Width has the significance ...
2
votes
2answers
147 views
Returning latest database ID
I want my method to use a finally block so I can be ure that my EF entity is disposed after usage, even if an exception is thrown, but I would also like to not ...
4
votes
1answer
35 views
Stop Watch Application 2.1
After the tips from my previous review. I have come up with these changes:
Separation of Concerns
Use Delegates
I'm asking you guys if this looks good. Other then separate out the ...
7
votes
2answers
91 views
Applying a 'mean filter'
I am just trying to apply a "mean filter" with C#. The working code below gets window size (3,5,7,9,...) from textBoxWinSize and applies the mean filter.
I am new ...
3
votes
1answer
44 views
Easier way to handle a Console Theme System
I'm just curious is there an easier way to handle console colors rather than just doing something
like the code below. The problem is the code bloat I'm experiencing when writing a theming system for ...
5
votes
1answer
52 views
Dictionary Key look up with variable length inputs
I am decoding GS1 barcodes and need to match up application identifiers with relevant data about them.
...
-1
votes
0answers
14 views
Example: Interfaces for adding data to a collection (readability, extensibility) [on hold]
I'm looking for some good practice advises regarding designing class interfaces where multiple methods should be provided to do a single task. As an example: Adding data to a collection.
Requirements
...
4
votes
3answers
98 views
Click handlers for two to ten buttons
I have click event handlers for two buttons. The code is working well, but I want to apply the DRY principle. How should I rewrite the following code in the button_click event handler so that I don't ...
-1
votes
0answers
14 views
method to receive wholesale cost and markup % as arguments and return retail price c# [on hold]
I typed out this code for homework and it works. However, the method part is incorrect. The method should receive 2 values (wholesale price and markup percentage) from the form as arguments and return ...
0
votes
0answers
30 views
Correct usage of Repository Factory Pattern? [on hold]
My repository pattern is setup like this:
...
0
votes
0answers
18 views
Handling WinAPI return values and errors without code being verbose [on hold]
I'm trying to come up with a way to streamline a bunch of WinAPI calls that return true or false without having a bunch of ...
1
vote
2answers
36 views
Double Inclusive Range step by step
I've written a method to obtain an IEnumerable from a start point, end point and step. Similar to Enumerable.Range() but for doubles and not fixed step.
...
1
vote
1answer
30 views
Authentication with JWT
Please review my code for 'JWT' authentication.
Are there any security issues?
Where should I store the secret's key, DB or InMemory?
What's a good 'JWT' Lifetime?
Should I send the 'JWT' in Header ...
1
vote
2answers
63 views
Normal distribution array function [closed]
I have a function that produce an array with values that are Gaussian(normal) distribute. If you plot the values on a graph, it would look something like this:
Is there any way to improve on the ...
2
votes
0answers
38 views
Generic repository pattern
Please have a through look my custom implementation of generic repository pattern and suggest anything I may be lacking.
I am using a generic interface with 6 methods
I'll be using a repository ...
0
votes
1answer
40 views
Is a single instance of reusable HttpClient a bad idea?
I've got a method shown below and I realize that an instance of HttpClass is going to be created for each call to it. While working seemingly OK, I consider moving it out and place it as a private ...
2
votes
1answer
63 views
CSV writer implementation refactored
Based on my initial implementation found here and the suggested improvements in answers and comments, I've refactored the code.
The main changes are:
Removed redundant buffering.
Simplified ...
3
votes
3answers
484 views
Code optimzation by constant if-structure iteration removal
Below you will find the specific code that I am attempting to optimize. I have a method previous to called getCount() which, based on similar parameters as below, ...
6
votes
1answer
144 views
CSV writer implementation
I've recently been assigned to write up a CSV writer with "as much flexibility" as possible concerning pretty much all (output stream, string fields with potential new line characters, separator ...
3
votes
1answer
66 views
Compressing a stream asynchronously, and returning a byte[]
Assuming I have to leave the contract intact (take byte[] and return byte[]), what's the correct way to structure this ...
6
votes
0answers
55 views
Mutual Exclusion with Mutexes
After I wrote this question: Producer/Consumer programs, I realized that I had forgotten to write a version using mutexes. I have now written a Producer/Consumer problem solver using mutexes using ...
17
votes
2answers
446 views
Where equations are born and mutants are buried
I've read up on genetic programming yesterday so I figured I'd try to implement something myself. I would like the main focus to be on whether or not I've implemented the idea behind it correctly.
...
2
votes
0answers
36 views
Dapper helper service
I've written a very light wrapper around dapper to help with unit testing and streamlining the dapper commands I need. Execute() is a method created to remove the ...
2
votes
2answers
244 views
c# best way to declare a class-level value in base class and set it at derived classes [closed]
I have a root class and I'd like to add an indicator to it (property, static field, readonly field, virtual method or something like that), that should give me the same string value for every instance ...
3
votes
2answers
266 views
Getting valid URL from user input
I have a dialog which populates my ConnectionStringData object with the URL of the service that I'm trying to connect to. I then consume that URL with the following ...
0
votes
2answers
72 views
Connecting to a MySQL database with C#
Can anyone help me with checking this code? It is for connecting to a database. The method getFromDatabase is to take values from the database and put it to a ...
4
votes
1answer
57 views
I am porting some C++ standard functions into C# for verification (matching results)
Can you help me look through the functions below to make sure they behave similarly as these standard C++ functions (_fcvt, ...
5
votes
3answers
82 views
Could this QuickSort be made more consise and “nicer”?
After seeing this example of a "primitive" QS implementation in F# by Scott W
...
5
votes
1answer
78 views
Random interval generator for a game
I have been working on a few games which all have a need to create "events" randomly over time. The intervals need to get shorter as time goes on if the event is negative or they need to get longer ...
3
votes
3answers
83 views
Registration and Login: Best way to separate responsibilities
Based on lots of read books, sometimes I get quite confused when things get bigger than the simple examples. Martin Fowler's clean code is good but not enough.
I want some feedback on how to improve ...
4
votes
2answers
97 views
.NET REST API JSON Filtering
My question, REST API and lazy loading objects, didn't receive any answers (or many views), so here is my attempt at the solution.
Problem overview:
My mobile app requests a list of objects through a ...
4
votes
3answers
394 views
Shapes that can be saved to a database
I have been asked to refactor the below code using SOLID principles and I was just wondering how you would go about it. I am not really sure if I am winning or not.
Could you have a stab at it and ...