C# is a multi-paradigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform.
3
votes
1answer
20 views
ASP.NET core proper way to work with the repository pattern
I am currently working on my first ASP.NET Core MVC project with a repository pattern.
I have gotten it to work but I wonder if there is a better way to solve this.
In this case I have an ...
1
vote
0answers
22 views
C# GDI+ rendering method performance
I am looking for any performance insights or better coding style for my rendering method.
...
2
votes
0answers
23 views
Splines on Unity3D
I've written this small code chunk to implement a very basic spline system for object motions. As I've only used C# on Unity3D so far I would appreciate feedbacks on this, especially on access levels, ...
1
vote
0answers
32 views
Player statistics class architecture
I've made a stats hierarchy for my Unity game project, it consists of 1 base class and few derived ones.
abstract class Stats : MonoBehaviour
...
2
votes
1answer
41 views
EF code-first solution architecture, which exposes freely the data repo to the UI controllers
I have a project template and like to usually work with the following setup (grossly simplified, but that's the gist of it).
CompanyName.ProjectName.Business.Entities
I define my business objects. I ...
-1
votes
0answers
28 views
Task with Action Delegate accepting string parameter [migrated]
I have just started with parallel programming. I want to create an action delegate method that print a message on console. when i chenge Action<string> to <...
-4
votes
0answers
38 views
7
votes
3answers
387 views
Word Pattern challenge in LeetCode
I solved this problem from LeetCode:
Given a pattern and a string str, find if str follows the same
pattern.
Here follow means a full match, such that there is a bijection between
a letter ...
1
vote
4answers
58 views
Switch / Dictionary containing multiple values with same keys
I have different strings that will return different integers, though some strings have the same value (usually 4 per code).
I used a Dictionary first, and still ...
-3
votes
0answers
24 views
Branching out code inside and outside of a loop [on hold]
I have a method that contains a loop inside and some code before that. There is a condition that is checked in both before and inside the loop.
In short, it looks something like this:
...
3
votes
2answers
60 views
Chain of commands
I need to execute several commands in a specific order but before I excute the main command, another command needs to be executed first and in some situations there are more commands that also need to ...
3
votes
1answer
51 views
Extracting complete lines from a data stream
When reading from the Console, it's very easy to get a complete line, you simply call Console.Readline.
When reading from a ...
3
votes
2answers
54 views
Loading items from XML document
I'm making a game in Unity and I need to have a inventory/item system, I decided to store my items in simple XML document which I later read from. I'm planning to have different varieties of items and ...
0
votes
2answers
87 views
Memory issues when copying JPEG into bmp
I am trying as a part of a bigger job to merge parts of several JPEGs into one huge BMP which will be processed further.
As a start, I tried to just copy a few JPEGs each to his own BMP file. In ...
3
votes
0answers
37 views
Working with threads - shared access and graceful cancellation
I've created this program to show how to stop threads in a controlled manner.
Important points in the program:
Starting and waiting for threads
Exception handling
Stopping threads in a controlled ...
5
votes
4answers
657 views
Generic Null/Empty check for each property of a class
I have created a method to check for null/empty values of class properties and if any null property is found I'm stopping the checking process and returning the result as true. I'm used a solution ...
5
votes
2answers
129 views
Faster brute force algorithm
I have this brute force code, where you input a password and runs through combinations of numbers, lowercase and uppercase letters, and special characters until it match the password given.
The ...
0
votes
0answers
38 views
Connecting to a database with ADO.NET [on hold]
We are using ADO.NET to connect to a database in all the web applications we are developing. Normally there are few people using the systems and in a new web application there are more users than ...
0
votes
0answers
63 views
Two similar methods to specify chamfers and fillets [on hold]
I have two methods with a similar signature (ChooseChamfer and ChooseFillet). These methods have an extensive structure ...
-3
votes
0answers
27 views
Login ASP.NET MVC C# without Entity Framework [on hold]
I'm working a system in ASP.NET with MVC 5 and I'm new at this, so I need help with the login part in my system, the thing here is that I need to work the login without entity framework and using a ...
0
votes
0answers
27 views
Implementing bulk big data insertion in async EF [on hold]
I am trying to parse a large data file (say 450MB of 380-bytes long lines) and insert corresponding records into MySQL database as fastest as possible, using Entity Framework.
Normally, in Java/...
1
vote
0answers
40 views
Instantiate repository classes dynamically
I'm curious about the best way to instantiate my repositories. Currently they're in the main controllers constructor method.
I was thinking making separate controllers for inbounds, outbounds, ...
2
votes
0answers
54 views
ExceptionPrettifier for prettier exception strings
I've been refining my previous idea for pretty exception strings and made the following changes:
Exceptions can be ordered.
Prints all properties including Data.
...
1
vote
1answer
34 views
Simplify TcpListener application in C#
I have a simple application that can receive and send tcp data.
right now there's a thread used to start the listener and within this thread there's another thread to receive.
it works but it seems ...
7
votes
1answer
913 views
Base64 implementation in C#
I've written the following unsafe C# method to convert a byte array to Base64 encoding. It works, but it runs at a significantly slower rate than the built-in ...
4
votes
2answers
85 views
Clean batch inserts with EntityFramework
Always the endeavour to write cleaner code or in general better code.
I have a scenario where I receive an object OrdersRootObject which contains a list of Orders, BillingInfo, ShippingInfo, ...
4
votes
2answers
232 views
Automatic IEqualityComparer<T>
There are APIs like the Except extension that require the IEqualityComparer<T> to work. I find it's too much work for such ...
8
votes
3answers
868 views
Composing CPU instructions by merging four short hex strings
My code shares some values with its neighbor. The names "Instructions, Registers" can be ignored in the comments; just see them as "names". What's important is how they are shared, which can be seen ...
3
votes
0answers
66 views
C# AES Encryption random IV per file
I've made some improvments on the code from : Csharp-AES-bits-Encryption-Library-with-Salt
saltBytes is now the SHA512 of the password.
Random IV for each encryption call. ( IV length 16 is added to ...
2
votes
1answer
74 views
Simple multi-client echo server
I've been looking at some async comms in C#. As a proof of concept, I've written a simple multi-client echo server. The server allows multiple TCP clients to connect and listens for input from the ...
0
votes
0answers
22 views
Checking if a sub string is an anagram of another string using an array [closed]
I am trying to find time complexity of my code in c#. Please provide let me know if there is a better way to code it as well.
Edit: the problem here is actually this that er need to verify if a ...
4
votes
2answers
59 views
ConcurrentDictionary, Store Key and Compression
So i have a ConcurrentDictionary<int, string>
The "int" is merely the way i store the key, which i want more recommendations on.
Currently i do like this.
...
4
votes
1answer
94 views
Binary search tree implementation in C#
I have implemented a BST for an assignment in C#. I am still in the process of implementing IEnumerable and ToList functions but ...
3
votes
1answer
56 views
Managing documents with manager class
So I have a program that visualizes data from files (csv,txt,etc.). These files are saved to database as individual tables. In my application I have DocumentExplorer...
1
vote
0answers
30 views
Concurrent SSH session pool
In my application I need to perform several SSH commands from Windows to a Linux machine.
Since I need to reduce as much as possible the SSH calls overhead and also limit the number of concurrent ...
4
votes
1answer
71 views
Code that uses reflection to validate arguments
I wrote an answer to this question on the Software Engineering SE site and was hoping to get it critiqued. (I'm told that it's acceptable to do so).
Essentially, this code uses reflection to check to ...
4
votes
0answers
36 views
Parsing cron expression
I'm building my own scheduler and I took the first step by creating a cron expression parser.
To test it I used this expression to cover each case. (I guess the 52W is wrong but this doesn't matter ...
3
votes
3answers
56 views
Presenter creating Views in c# MVP
I have a c# WinForms application in which I have tried to implement the Model View Presenter pattern with Passive View. I create new Views in the Presenter of my 'home screen'. I was wondering if this ...
6
votes
5answers
271 views
Another DataGrid (ObservableCollection) Filtering Method
I have re-written my DataGrid filtering method to try to improve performance and I feel that although this is the fastest yet, there is still room for improvement ...
4
votes
2answers
188 views
Recurrent action on concurrent collection
I have a bunch of concurrent threads carrying out operations which return alerts. The alerts have to be persisted to a DB, but this cannot be done concurrently as it may cause duplicate alerts being ...
-2
votes
0answers
40 views
Subtract from line and move to next
I want to subtract from the line with oldest date and where counter > 0, and when it reaches 0 I want to subtract from the next oldest line with the same itemId and ...
5
votes
4answers
120 views
Loosely coupled movement
I'm working on my ability to write loosely coupled applications that follow SOLID principles. This is a simple application trying to demonstrate the concept. Is it OK? Am I going along the right lines?...
0
votes
1answer
69 views
Check if a string has HTML in C#
I need a function to determine whether or not a string has HTML in it or not so that I can know whether I'm dealing with a plain-text format or HTML format.
It seems simple enough in C#, using ...
3
votes
0answers
32 views
Converting MongoDB's IAsyncCursor(Source) into an Rx Observable Sequence
I've been toying with this idea for quite a while.
Needless to say that this really enables a lot of possibilities,
Especially when combined with a SignalR Backend.
Added below is what I came up with....
0
votes
1answer
58 views
Singly linked list RemoveBefore() method
I am trying to implement a singly linked list. What is the most optimal way of implementing a RemoveBefore(ListNode) method?
I have done this:
Check if node being ...
3
votes
2answers
321 views
Calculating the Collatz conjecture of a number
I've made a Collatz Conjecture sequence calculator and I would like some feedback on what I can do better in regards to the code I've implemented, i.e. bad practices you see, improvements that can be ...
3
votes
4answers
95 views
Optimizing algorithm of analyzing incoming data
I've been making an app, which gets data from external device (via bluetooth) and displays received data.
I'm still pretty new to programming and I'm struggling to finish this app.
I wrote some code, ...
1
vote
1answer
47 views
Simple TCP server using TPL
I have a working C# code of a TCP server that runs inside a windows service. It accepts incoming connections and starts sending/receiving data based on some complex rules.
The top-level class for ...
6
votes
0answers
64 views
CultureInfo with fallback routing to another language
Our company needs a localization/translation behavior which allows incomplete (ResX) resources.
If a String
isn't available in italian
fall back to the next roman language, like french
fall back to ...
10
votes
3answers
1k views
StackList<T> implementation
I needed a structure that works really similar to the predefined Stack<T> but with a few extra functionalities. Examples include getting the index of value in ...