C# is a multi-paradigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform.
1
vote
0answers
23 views
Organization of modular code. Not a service and not a model, where should it go? [on hold]
I currently have some code, which I'd rate as modular / loosely couppled, mainly because Seperation of Concerns is paid attention to:
Its not Uploads job to ...
3
votes
1answer
47 views
Class to move a sprite in Unity
I first got introduced to coding with Ruby and now I am learning how to create games in C# with Unity.
I am following a tutorial and I refactored the code to make it easier for me to grasp. I am ...
3
votes
1answer
40 views
Wrapper class for executing database queries
I have a wrapper class for executing database queries from an ASP.NET application. Please provide suggestions on how I can improve this class. It is working fine. Anyone can use this class in their ...
10
votes
4answers
251 views
Stack data structure implementation
I have implemented in C# a stack data structure, without using any existing C#/.NET containers (data structures). I have used TDD technique to implement this requirements, so you can find tests, too. ...
2
votes
0answers
38 views
LDAP search helper for System.DirectoryServices.Protocols
Given all the times I need to perform LDAP searches in the work I do, I wrote a helper and I want to clean it up and publish it to Nuget. What are peoples opinions of the approaches used?
...
7
votes
1answer
64 views
Vending Machine
After doing a lot of reading and practicing, I've come up with a simple program that implements multiple OOP techniques, principles and several design patterns such as Observers, Factories and ...
3
votes
0answers
68 views
Estimate π using an infinite series
Looking for style and speed review
π PI
An estimate is \$\frac{4}{1} - \frac{4}{3} + \frac{4}{5} - \frac{4}{7} + \frac{4}{9} - \frac{4}{11} + \frac{4}{13} - \frac{4}{15} + \frac{4}{17} \$...
The ...
-3
votes
0answers
21 views
Advide on Factory pattern with DI implementation [on hold]
I am looking on ways to improve the following code:
...
3
votes
3answers
125 views
Queue implementation using linked list
I have implemented a queue data structure using linked list in C#. I have also associated my implementation with unit tests. Is this implementation correct? Any suggestion?
...
0
votes
0answers
37 views
Job Interview time schedule intersection C#
I had a job interview one of the questions was the following
Given an api - you submit a name of a person and it gives back a sorted list of all the free time slots this person has. the list might be ...
4
votes
2answers
71 views
Deserializing JSON in an expression-bodied member
All of these if conditions in the below method have similar pattern, Any ideas to come up with a common method to reduce the duplication in this method?
some case we want all the version, and in some ...
5
votes
1answer
57 views
Rijndael compression/encryption class
Out of personal interest and as a learning exercise I've written a C# class (.NET 4) to perform encryption/decryption of a file along with some compression upon encryption. Most of my understanding of ...
2
votes
1answer
104 views
Reading multiple CSV files and asynchronously update SQLite
My console app needs to read several big CSV files to update its data, which are stored in a SQLite database. I am new to C# and would like to know if there are ways to improve this sample code I ...
0
votes
1answer
34 views
Fisher-Yates generic inside out shuffle in C# as per dotnetperls implementation [on hold]
Dotnetperls has the following implementation of the Fisher-Yates shuffle algorithm. I personally don't understand the way of generating the randomIndex.
...
2
votes
1answer
46 views
Read characters slowly (Threading with delay, .NET Framework 2.0)
Couple of months ago I was asked to develop a console app to do the following:
Write an application that takes an array of ICharacterReader
interfaces, accesses them in parallel, and outputs a ...
4
votes
1answer
51 views
Online examination portal for learning
I am new to ASP.NET and I just developed a simple online examination portal for learning. I used ADO.NET, MySQL and developed in VS 2010.
I have a login page in which the user can login and register ...
3
votes
1answer
43 views
Guess a number between 1 and 100 (revision 2)
Further revision based on comments (Guess a number between 1 and 100 (revision 1)). Is there any issue with using DisplayBeginMessage in the ctor (¿constructor?) of ...
4
votes
3answers
1k views
Game Permission System
I have just finished coding a permission system for my game server but one method in the class is seeming to be very complicated, and maybe some people on this site can help me improve the method?
...
19
votes
8answers
6k views
PI Calculator, Interview Challenge
Greg Beech says here that he asks C# candidates to produce a formula that calculates PI Given that Pi can be estimated using the function \$4 * (1 - \frac{1}{3} + \frac{1}{5} - \frac{1}{7} + \dots)\$.
...
5
votes
2answers
58 views
UnitOfWork for sending mail
Topic is about a LoB web application written in C# for ASP.Net Core. We're following the blue book DDD architecture. We're using SimpleInjector as dependency injection container. Every request opens a ...
1
vote
1answer
39 views
One method for changing one of the properties C#
I have a few resources set in my class – coins, diamonds, hearts, enum of these resources names, and method for increasing specified resource. I want to make single "Increase" method for all resources ...
5
votes
2answers
97 views
SpaceSort - A new sorting algorithm
A sorting algorithm i have written.
Pros
- Gives each element a position once.
- Few comparisons needed.
Cons
- For certain sets of data, large amount of extra storage is needed.
- Only works with ...
3
votes
2answers
44 views
Static ConcurrentDictionary to maintain static objects
I am using following code to maintain some static information. The problem I see with it is that, if the information retrieved using GeKeysFromCache is modified without using lock keyword it may lead ...
6
votes
2answers
102 views
A simple program which returns specific value from array
After researching for an hour regarding SOLID Principles, I tried to do it myself. Please note that most of these codes were from the ideas of others.
I created a simple program which returns ...
2
votes
1answer
30 views
Replacing DataContract serialization with Binary one in Azure Service Fabric
Azure Service Fabric uses DataContract serialization, which is a total disaster – it violates LSP (wiki) - see all those ...
3
votes
1answer
67 views
Guess a number between 1 and 100 (revision 1)
I have taken the critiques from the original post and tried to refactor. I used int.TryParse and that cleaned up quite nicely. What can I further improve on?
Edit: (Guess a number between 1 and 100 (...
0
votes
0answers
33 views
Use of Static Dictionary Across Different Instances of a Class [on hold]
I have a class which will have two instances and those two instances will be accessed by two different threads. I want to have a dictionary that is accessible from both the threads(with different ...
1
vote
1answer
53 views
Composing best web page fetcher function by HttpClientHandler for C#
The returned class as result:
...
4
votes
0answers
32 views
Trying to develop evaluation function for minimax/alphabeta algorithm
I am trying to develop an optimal evaluation function to use in minimax/alpha-beta algorithm for developing tic-tac-toe AI.
I am counting number of circles/crosses in a row/column/diagonal with ...
8
votes
2answers
104 views
Library for the Summary API (used to get summaries of webpages)
I was wondering if I could get some pointers on how I can improve my library, whether it be design pattern/naming convention/or any ideas on a better implementation.
GitHub
As it stands, I am using ...
7
votes
2answers
87 views
Fixed size dictionary to achieve performance goals
In my open source project, I have code that use a dictionary very intensively so system dictionary implementation did not suit me due to performance reason. Therefore, I decided to write my own ...
7
votes
3answers
132 views
First C# attempt: Blackjack
I am learning c# and trying to wrap my head around OOP. This blackjack code is my first attempt. It works well enough, but it is probably terrible. Please let me know what to work on.
...
-1
votes
0answers
45 views
Findall then Parallel foreach
I have this very repetitive workflow I am doing again and again. I am trying to find a way to reduce redundancy as per DRY principal of programming.
Is there another more generic way of doing this or ...
9
votes
3answers
114 views
Splitting a string into groups of up to 3 numbers, or one letter and up to 3 numbers
There was an interesting idea brought up in The 2nd Monitor where one of our regulars was trying to split a bunch of strings into a specific format.
The format should be similar to the following:
<...
5
votes
1answer
80 views
Beginner Dice Roller
dRoll: Beginner Dice Roller
Roll dice base on a input string.
1/. Input.
<number_of_dice> d <value> [/ <modifier>]
...
4
votes
1answer
38 views
Update URL with new parameter value in controller action
I have an action that takes an id as a parameter and gets the corresponding item with the help of a web service. The web service's method that returns the item will either return the item with the ...
3
votes
3answers
59 views
Better way for many components?
I have coded a system where each 'Player' class requires 5 components (could be more in the future, up to 10, 20 maybe even 30, once we add more and more features). What I want some advice on is a ...
7
votes
2answers
2k views
Guess a number between 1 and 100
This is my attempt at writing a guessing game. Where can I improve my code to make it more succinct?
Link to Revision 1 (Guess a number between 1 and 100 (revision 1))
...
3
votes
0answers
126 views
Hackerrank: Kindergarten Adventures
Problem statement
Description:
Meera teaches a class of n students, and every day in her classroom is
an adventure. Today is drawing day!
The students are sitting around
a round ...
7
votes
2answers
179 views
C# beginner's exercise in calling methods
This is one of my first experiences with C#. I'm trying to learn and as can be seen, I need some obvious help. I know it's only an example but I'd like to start with best practices from the beginning. ...
3
votes
1answer
56 views
MySQL database library with multiple connections
I am writing this question to get some advice on improving this Database Management library. I'll explain a little about it:
Database Manager - DatabaseManager is ...
7
votes
1answer
63 views
Adding filters to images
Here is some code I wrote as part of a project that I am working on to learn C#. It is a class responsible for applying filters to images. In this case, my code offers filters such as sepia and ...
2
votes
1answer
39 views
Batch convert images to PDF
I wrote a simple program that converts graphic files in a folder to a single PDF using Magic.NET. It works fine. I'm interested in general comments about the code ...
5
votes
1answer
44 views
Pin an array in memory and construct a Bitmap using that buffer
I'm using some resources in the code below to pin an array in memory and construct a Bitmap using that buffer. I'm not sure if I'm handling all of the resourced in ...
15
votes
6answers
2k views
Login form C# SQL
Basically this is my first login form.
I am using SQL and C# WinForms.
I made user roles such as "Admin" and others and the user is taken to a specific WinForms, according to his appointed role (...
3
votes
1answer
56 views
Loading components on startup, with timing measurements
I was just wondering, is there a way to load these better and log the times they each took? It seems like a headache having to write about 90+ stopwatches, which is what I will have to do as I have ...
6
votes
1answer
134 views
switch to create number of symbols
This code shows an icons from the Segoe MDL2 Assets font, depending on the number in a variable. However, I'm sure there is a more elegant way of doing this.
...
3
votes
1answer
35 views
Dynamically initializing Context and creating connection string for Web API
Scenario:
There is a 20 years old windows application with SQL Server as database. There are 42 companies within the Group and each company has its own database.
Now we have started building new ...
1
vote
1answer
41 views
Creating custom control in Unity3D that has same UI but different behavior
I made some custom control named Range Control in Unity. It has two buttons a "plus" and a "minus" and an input field that shows the current value. The control has (for now) two implementations:
None-...
8
votes
8answers
672 views
Temperature conversion application
I'm two months in a programming course and our instructor told us we should think about building real-world applications as to gain valuable experience. I got the idea of doing a simple temperature ...