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.

705 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
18 votes
0 answers
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 ...
user avatar
  • 447
13 votes
0 answers
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 ...
user avatar
  • 231
10 votes
0 answers
863 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....
user avatar
  • 7,673
9 votes
0 answers
618 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 ...
user avatar
  • 5,522
7 votes
1 answer
183 views

C# Console Snake Game

I was busy writing an answer for this question when I realized that I was busy creating a new solution without explaining what the original poster did wrong, again. So I decided to rather post what I ...
user avatar
  • 2,247
7 votes
0 answers
619 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 ...
user avatar
  • 459
7 votes
0 answers
206 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 ...
user avatar
  • 43.8k
6 votes
0 answers
127 views

dotnet - creating db records in bulks in a background job

UPDATE: I found the namespace Channels, and this does exactly what I want to do, but in a much more stable way. Please don't use my code for anything important! :) Use case I have a site that (at peak ...
user avatar
6 votes
0 answers
199 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 ...
user avatar
6 votes
0 answers
240 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: ...
user avatar
  • 116
6 votes
0 answers
328 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 ...
user avatar
  • 171
6 votes
0 answers
175 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'...
user avatar
  • 61
6 votes
0 answers
773 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 ...
user avatar
  • 355
6 votes
0 answers
410 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 ...
user avatar
  • 43.8k
6 votes
0 answers
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 ...
user avatar
  • 161
6 votes
0 answers
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 ...
user avatar
  • 3,186
5 votes
0 answers
113 views

Parsing indented text into a tree structure in C#

My goal is to take an input stream (text file), and then parse it into a tree node based on each line's indentation. My rules are Lines can be indented using either tabs or spaces, but the file must ...
user avatar
5 votes
1 answer
391 views

C# Async FileInfo Extensions (Copy, Move, Delete)

Here is my effort to implement extensions for FileInfo object: ...
user avatar
  • 151
5 votes
0 answers
302 views

Multithreaded pathfinding in Unity C#

I've tried to implement multithreaded pathfinding in an attempt to increase performance, but if anything, performance seems to actually decrease when I enable multithreading. Is there anything I ...
user avatar
  • 151
5 votes
0 answers
50 views

SmartUnit: Unit Testing with DI

I was thinking about how unit tests require you to manually instantiate all your dependencies, even though many of them are the same for every test or don't really matter (such as logging, where ...
user avatar
5 votes
0 answers
117 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....
user avatar
5 votes
0 answers
141 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. ...
user avatar
5 votes
0 answers
59 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 ...
user avatar
5 votes
0 answers
107 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 ...
user avatar
  • 211
5 votes
0 answers
175 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-...
user avatar
5 votes
0 answers
121 views

Implement Sudoku using LINQ

WiKi and GitHub. Sudoku rules are being checked with the following tests: ...
user avatar
  • 6,113
5 votes
0 answers
135 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 ...
user avatar
  • 255
5 votes
0 answers
1k 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 ...
user avatar
  • 4,064
5 votes
0 answers
133 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 ...
user avatar
5 votes
0 answers
95 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 ...
user avatar
  • 43.8k
5 votes
0 answers
352 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 ...
user avatar
5 votes
0 answers
297 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 ...
user avatar
  • 43.8k
5 votes
0 answers
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 ...
user avatar
  • 43.8k
5 votes
0 answers
193 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 ...
user avatar
  • 101
5 votes
0 answers
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 ...
user avatar
  • 450
5 votes
0 answers
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# ...
user avatar
  • 175
5 votes
1 answer
286 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 ...
user avatar
4 votes
1 answer
56 views

Console Slot Machine written in C#

This is my console simulation of the Slot Machine in C#. Please take a look at this code and point out possible ways of improvement. ...
user avatar
  • 41
4 votes
0 answers
92 views

Simple Leaky Bucket Async and Low Footprint

I'm working on a simple Leaky Bucket algorithm. I have found a lot of samples on the internet, but something always bothers me. Most of them use Collections and DateTime to track current actions and ...
user avatar
4 votes
0 answers
86 views

License-holder editing application

I am building a WPF (Windows Presentation Foundation) application. And I'm trying to use the MVVM (Model–View–ViewModel) design pattern. It's fascinating and rewarding, even though it seems overly ...
user avatar
  • 141
4 votes
0 answers
94 views

Possible optimization for finding small bitmap in large bitmap in C# without unsafe code?

Background I am creating a tool to locate a small bitmap in a large bitmap by comparing each pixel. Since I am by far no professional programmer, I was searching for some code snippets and found this. ...
user avatar
  • 41
4 votes
0 answers
263 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 ...
user avatar
4 votes
0 answers
261 views

BitVector64 implementation

I have implemented a structure to handle BitVector64 (default System library support only 32 bits). In the implementation i have added some custom method to manipulate bits inside the vector. I would ...
user avatar
  • 163
4 votes
0 answers
130 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 ...
user avatar
4 votes
0 answers
70 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 ...
user avatar
4 votes
0 answers
96 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 ...
user avatar
  • 141
4 votes
0 answers
117 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 ...
user avatar
  • 75
4 votes
1 answer
180 views

Payment system migration

GitHub There need to be a software design supporting gradual migration from one payment system (E-xact) to another (Stripe). Credit cards data are stored outside, so I would like to use both systems ...
user avatar
  • 6,113
4 votes
0 answers
164 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 ...
user avatar
4 votes
0 answers
95 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 ...
user avatar

1
2 3 4 5
15