Questions tagged [c#]

C# is a multi-paradigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform. Use this tag for questions related to C#. In case a specific version of the framework is used, you could also include that tag; for instance .net-2.0.

641 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
14
votes
0answers
4k views

How to stream data directly from the database through a 3 tier architecture

The problem: generating a CSV file that is too large be stored in memory in a 3 tier architecture, without the complexity of saving the file to storage. The solution: I've managed to write something ...
10
votes
0answers
3k views

Socket application using TPL

This is an application I wrote that allows multiple TCP clients to share a single TCP connection to a remote server (hosted project, and a demo). Traffic generated by the server is forwarded to all ...
9
votes
0answers
416 views

Geode Contents Predictor StardewValley Mod

The goal I really enjoy the game Stardew Valley. One of the things that the game has are geodes. Much like real-world geodes, these geodes can be cracked open, and you can find some fun things inside....
7
votes
0answers
422 views

Unity3D shader for rendering 2D sprites with a pseudo-glitch effect

I'm making a puzzle game in Unity with sprite-based graphics. When the game is paused, I want to hide most game elements, because I don't want the player to be able to pause and leisurely think about ...
7
votes
0answers
536 views

Sieve32FastV2 - A fast parallel Sieve of Eratosthenes

I’ve created a much cleaner, better designed version to my parallel sieve. I’ve implemented most of EBrown’s micro-optimizations but also revamped the code on my own (that is not in direct response ...
6
votes
0answers
95 views

C# Generic high performance vectorized math operations

I'm writing a library which simplifies the usage of intrinsics in C#. It's a generic library which supports all numeric types. The goal of this library is to perform these operations at the highest ...
6
votes
0answers
186 views

Display Child View and Subscribe to its event on ReactiveUI

I am very confuse what is better approach to display child view and subscribe to its event on ReactiveUI WPF, so far I have 2 implementation that somehow works for my case: Implementation 1: ...
6
votes
0answers
231 views

TPL Dataflow - Timer Action Block

I'm new to TPL Dataflow and was looking for an action block to basically push an object on a timer - specifically to produce heartbeats on every interval. I was unable to find anything out of the box ...
6
votes
0answers
127 views

Single-threaded fully asynchronous server, with a SocketSelector that dispatches events

I need a fully asynchronous single-threaded server written using .Net Core. Searched for options and, surprisingly, did't find any. So I decided to write a simple prototype. Borrowed idea from python'...
6
votes
0answers
523 views

Recursive conversion from ExpandoObject to Dictionary<string, object> #2

Because my original question was lacking many details, I have been advised to ask a new question. I will repeat the important parts of the original question and add examples etc to hopefully make it ...
6
votes
0answers
177 views

Scheduler built with observables v2 (follow-up)

It would probably be too easy if the old Scheduler worked as intended being that simple. But an eye-openig review showed that from time to time it'll miss one ...
6
votes
0answers
2k views

Authenticate ASP.NET Web Api 2 using OWIN and Firebase

I'm about to go live with an app, and would, therefore, appreciate a review of my firebase authentication setup. I haven't been able to find many resources describing how to perform such ...
6
votes
0answers
2k views

MSTest Data Driven Test Inline Data

Background: Didn't what to have to reference bulky 3rd party lib for inline data driven tests and wanted to use standard MS testing framework. Created helper ...
6
votes
1answer
170 views

SortedList performance

I've found my app, which uses the SortedList, has a poor performance. So I decided to try to improve the performance of my app. I created the ...
5
votes
0answers
106 views

Thread safe optimized list

Last week I was challenged in a technical interview with a code challenge about threads and efficiency. The challenged required to create a service to detect whether an ID had been already seen or not....
5
votes
0answers
80 views

At 8:00 AM in C#

I'm doing a planning tool for users around the world. A feature is that something has to be ready at a user-specified time of day. I imagine this being a TimeSpan. For argument sake let's say 8 AM. ...
5
votes
0answers
50 views

Finding collision between two Images using virtual Rect

I'm making a game. There is a turtle and lots of platforms it can walk on. It walks on its own and you can change the direction it is walking. I implemented a working logic, but I think it can be ...
5
votes
1answer
103 views

c# Efficient solution: Sequence generator for a pattern

This is an interview question to generate the below pattern of numbers in a sequence, which is: 12.34, 23.45, 45.67, 78.910, 1112.1314, 1617.1819, 2223.2425, 2930.3132, 3738.3940, 4647.4849, 5657.5859,...
5
votes
0answers
104 views

Production planner

I have a class that creates an object, PlannedYear, and then passes that object into several other classes to manipulate it. The ultimate goal of the class is to ...
5
votes
0answers
127 views

Using ClientFactory-pattern with Dependency Injection

I initially posted this on Stackoverflow but was recommended to try here instead. I'm looking for feedback on why the implementation of my ClientFactory is probably bad, from a Dependency Injection-...
5
votes
0answers
103 views

Winforms MVP Validation

I have a Winforms MVP application where I need to use the ErrorProvider on the view. I have added the following methods to my presenter to allow me to show the ErrorProvider but it just doesn't feel ...
5
votes
0answers
724 views

Auto register Func<T> for .net core dependecy injection

The default .net core dependency injection doesn't support building Func<> for injection automatically, see question. I wrote an extension method to go find all the Func in register types ...
5
votes
0answers
117 views

Prototype GameManager for game written in Unity

I am self taught, so I'm consistently seeking ways to code better, and more efficiently. If anyone has the time, please advise me on what can be done better with explanations as to why the old method ...
5
votes
0answers
288 views

Chaining JSON transformations with visitors

I have currently two use-cases that require JSON transformations before it can be deserialized. The first use-case requires changing the custom short type property name from ...
5
votes
0answers
87 views

Testing application stability by throwing random diagnostic exceptions

I'd like to be able to better test application stability. Usually when you're doing this, you run the application and keep your fingers crossed that it won't crash when an error occurs (be it a ...
5
votes
0answers
303 views

Creation of matrix with specific attempts at the end

What I want to do is build a Slay-the-Spire-like Map. As you can see in the following image, the map is splitted in ISteps and ...
5
votes
0answers
248 views

Extendable REST-Client - follow-up

My previous RestClient wasn't disposing a lot of resources. I've fixed it (hopefully without introducing new issues) and because a few new patterns emerged I did a ...
5
votes
0answers
4k views

Merging multiple app.config files

I have a few complex app.configs that I constantly manage to break. This often costs me a lot of time until I find the error/typo. To prevent such situations in future, I wrote a simple utility that ...
5
votes
0answers
188 views

WebPage LogReader class - Parallel DNS w/timeout for computer IP's and domains from log scrape

This is a namespace to read a bunch of events from a log file and display them in a table on a webpage, some additional data (computer domain and IP address) is also pulled in from DNS. I am mostly ...
5
votes
0answers
1k views

OAuth2 login for ASP.NET Core without local accounts

I am using OAuth2 for users to sign in with their Google Account and authenticate Google API requests. I have not used the built-in ASP.NET Identity provider because this requires an app database of ...
5
votes
0answers
2k views

Gracefully shutting down a HttpListener

I have worked out a code for graceful shutdown of a httplistener. However, I am not sure if its foolproof. Below I provide c# code and the powershell (v3.0) scripts I've used to run my tests... C# ...
4
votes
1answer
63 views

Minimum number of copies of an application a company needs to purchase

Some applications from vendors are allowed to be installed on multiple computers per user with specific restrictions. In our scenario, each copy of the application (ID 374) allows the user to install ...
4
votes
0answers
169 views

Simple target shooter game using Windows Forms

Currently, my game is a basic target shooting game. The targets rise to the top, if the target reaches the top an end screen is shown. If you shoot a target you get more score, and the speed in which ...
4
votes
0answers
110 views

Repository pattern method implementation with entity framework and C#

I have two entities in my database: Employee and Shift. I want to implement a C# repository pattern method, that given two ...
4
votes
0answers
60 views

Is there a better way to unit test a repository for a large aggregate root?

In our project we use domain-driven design and our customer aggregate root is large. The unit tests for the aggregate root itself are simple (~50 or so tests), but I am struggling with the repository ...
4
votes
1answer
108 views

Extracting member-accesses from an expression in C#

I need to extract all member accesses to expression parameter (and make sure, that they are not nested). For instance, for expression: a => a.A + a.B I need to ...
4
votes
0answers
62 views

Sharing User Inputs via Dependency Injection

This code solves the problem of how to share user inputs throughout a large application when using dependency injection. To achieve this, I'm using a static (through DI) store and injecting it at ...
4
votes
0answers
109 views

unsafe bit reading.in parallel

After referencing http://csharpexamples.com/tag/unsafe-bitmap-access/ I tried to put together one for 1 bit per pixel bitmaps. If you can review this, it would help me greatly in verifying this is ...
4
votes
0answers
107 views

Implement Sudoku using LINQ

WiKi and GitHub. Sudoku rules are being checked with the following tests: ...
4
votes
0answers
99 views

Running a JavaScript program from C# with sandboxing

I am using EdgeJS in my application. The application is used to run a user-provided javascript program from C#. Because we allow execution of user scripts some sandboxing is required. I am using vm2 ...
4
votes
0answers
82 views

RSS Reader from Multiple sources

I am writing a RSS reader Library which should be able to read the data from different sources. I am very new to writing libraries and not sure if I am going right with it. These are my base ...
4
votes
0answers
104 views

Toggle any application feature ON or OFF - follow-up (v2)

This is the second version of my FeatureToggle service (see previous question). It still has the same purpose which is to help control whether a feature is ...
4
votes
0answers
158 views

Return different types from web scraper method

Application Logic The software take odds data from an internet site and store them inside my own database, this application is basically a scraper. There are different types of odds, eg: FullTime ...
4
votes
0answers
65 views

MVC Controller Error & Exception Handling .NET Core

I'm putting together a basic web app in .NET core 2.1 MVC to try and better understand how it works. Currently I'm working on returning validation to the UI. Once I have this working I then want to ...
4
votes
0answers
93 views

Improved Knuth-Morris-Pratt over a source of indeterminate length

Following the successful review of my previous implementation. Please review my new, generic implementation of the Knuth-Morris-Pratt algorithm. Its modified to search a source of indeterminate ...
4
votes
0answers
2k views

Design an object oriented parking lot

I solved this system design interview question. The problem description Design a parking lot Constraints and assumptions What types of vehicles should we support? Motorcycle, ...
4
votes
0answers
98 views

One interface for multiple CRUD resources

I asked about an abstraction layer for accessing files (link) a couple of days ago (I decided to not call it a follow-up anymore as there are too many changes). I tried to incorporate many of the ...
4
votes
0answers
76 views

“Lock-free” one-shot event manager

Giving a review to Oachkatzl and recently about some other synchronization problems (Lazy with invalidate and some node-locking list), I wanted to test my skills and redesign it in most light-weight ...
4
votes
0answers
1k views

Generic Unit of Work implementation

I am implementing the unit of work pattern to be used in the logic layer of my application. The goal is to abstract away the tasks of managing transactions / connections. My implementation relies ...
4
votes
0answers
273 views

Rabbit MQ long running de-queue by using IEnumerable yield return

The following code attempts to efficiently stream queue messages to processing units using an IEnumerable yield return. create a blocking collection to handle the stream create a linked token source ...

1
2 3 4 5
13