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.

484 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
0answers
29 views

Unit sprint mesh rendering

I have built this code in the past and I am reviewing it once again. I have a feeling that I could make the code much faster. Could someone please look at the code. What happens is that every time ...
2
votes
0answers
200 views

Control for displaying error messages

I am working on a WPF application consisting of a tree view and multiple "view parts" that display details about the selected node. The content of the view parts are loaded asynchronously which may ...
2
votes
0answers
441 views

C# MySQL Database Library

Below is a database manager and a class called database connection. The database Manager controls the database connection string and generates a new database connection when you need one. I'm looking ...
2
votes
0answers
47 views

Creating many aspx pages

I just want to ask if its okay to create many aspx pages. What i did was, i made a guitar store website that has 6 brands and each of them have their own webpage. The code is like this: The aspx.cs ...
2
votes
0answers
149 views

MVC routing with duplicate method entry points

The 3 methods below all need to have the same name: "Roles" They need to be the same as I have a permissions system that will only allow the execution of a "Roles" method. I don't feel too happy ...
2
votes
0answers
540 views

ASP.NET web API handling dynamic connection string

I have a project where it is an absolute requirement that each client is on a separate database. My design is to use a class that builds the connection string from the ...
2
votes
0answers
71 views

Time Schedule Intersection version 2

Time schedule intersection in my original question I gave an answer which has \$O(n^2)\$ complexity. Here is the new version of the same problem. I'm trying to get to O(N+K). please review the code ...
2
votes
0answers
1k views

Using Prism to Inject and Navigate Views?

So I have been trying to learn Prism and use it with my project. I am also trying to use the MVVM pattern. So basically, I want a experts advice or opinion on how I setup my program. I've been trying ...
2
votes
0answers
8k views

Use NPOI to read string value of all cells in a row in xlsx file, including merge cell

I'm currently using NPOI library to read the value of all cells in one row of a xlsx file and return a List<string>. However, if a cell is part of a merged ...
2
votes
0answers
617 views

Hackerrank: Max Score

Problem statement Consider an n-element sequence of integers, A = {a0, a0, ..., an-1}. We want to perform \$n\$ operations on \$A\$, where each operation is defined by the following sequence of ...
2
votes
0answers
512 views

Routing simulation (Distance vector)

I am trying to write simulation for routing algorithm by distance vector. I will explain my class and how it works a bit, and then, introduce three main issues I encouter. Important to mention that ...
2
votes
0answers
596 views

Simple files parsing and info extraction

First let me describe the problem, we want to solve: We have hierarchical directories structure with different types of templates. Each type of templates is located in dedicated folder. Hierarchical ...
2
votes
0answers
133 views

Send image between apps

I have an ASP.NET CORE API app and now I have an endpoint like: ...
2
votes
0answers
74 views

Creating & reading CSV with system own tools

There are lot libraries for creating/parsing CSV but how about not using any of them and instead use Windows own tools like PowerShell? I thought I'll try and create some extensions for that purpose ...
2
votes
0answers
636 views

JObject Pattern Matching: Merging partial WEB API JSON payload

This library [GitHub] helps merging partial WEB API JSON payload with existing prepopulated DTO objects. Let's say that JSON is represented by JObject from JSON.NET package. Naïve implementation ...
2
votes
0answers
363 views

Unit of Work pattern for NHibernate

I have the following code implemented in C# for NHibernate: ...
2
votes
0answers
2k views

Unity3D Property Drawer for a MinMaxSlider

This is a bit of an interesting one. Read about custom Property Drawers in the Unity Docs. Read about MinMaxSlider in the Unity Docs. Unity's ...
2
votes
0answers
220 views

Navigation Menu Code went from mvc controller into the view model

Sometimes code seems to write itself (kinda like a donut seems to eat itself) and that happened in this case, but I have thought that UI view models (MVC models folder) were supposed to be stupid to ...
2
votes
0answers
191 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 ...
2
votes
0answers
272 views

Entity Join slow query

I've never participated in a codereview before and I was pointed that I should in another thread for a slow query. ...
2
votes
0answers
533 views

Implementing Async Objects/Collections in C#

I think that in terms of just general C# programming, I'm a pretty decent programmer, but am trying to develop my skills in the asynchronous/parallel area. I can get by using the TPL, but am ...
2
votes
0answers
102 views

Making HttpWebRequest and not really interested in the response

I am working on top of existing application and I have this (original) method for making a HttpWebRequest: ...
2
votes
0answers
99 views

Fetch object from database, or fetch it using an API if it isn't there

To give some background on this particular code, there is a controller which recieves an object, hashes parts of it and looks into a database to see if there is a similar hash in the db, if there is, ...
2
votes
0answers
540 views

Producer / consumer pattern with limits on .NET

For a project that I'm developing, I need to implement the producer/consumer pattern, but the quantity of consumers cannot be higher than some number (say 40). I created a concept project on GitHub ...
2
votes
0answers
54 views

Api occasionally slows down at runtime, possibly due SQL/connections

I'm currently working on an API that behaves incredibly unpredictable at runtime. Context: We run the same call 100 times without delay in between. A call can take anywhere from ~200 ms to ~5 seconds. ...
2
votes
0answers
1k views

Leetcode 317: Shortest distance from all buildings

Problem statement: You want to build a house on an empty land which reaches all buildings in the shortest amount of distance. You can only move up, down, left and right. You are given a ...
2
votes
0answers
835 views

Hotkey-System for command-based WPF applications

I wrote a Hotkey-System for command-based WPF applications. Could you please take a look at my code (even if it consists of multiple classes :P). I am mainly interested in following things: How ...
2
votes
0answers
451 views

Passing a complex object across cross domain

I am working with two web applications, one is webform-based Site1 and other is an MVC application Site2. TODO: Pass a complex object from Site1 to Site2. In response get View from Site2 to Site1 ...
2
votes
0answers
401 views

HackerRank university codesprint array construction

Problem statement Professor GukiZ has hobby — constructing different arrays. His best student, Nenad, gave him the following task that he just can't manage to solve: Construct an \$n\$-...
2
votes
0answers
1k views

HackerRank - Matrix Rotation

Problem statement Given a matrix (up to 300 × 300), rotate each element R steps anti-clockwise along concentric rectangular paths (R up to 109). The algorithm is rated as hard on HackerRank. On ...
2
votes
0answers
108 views

Z sorting implementation for a 2D isometric game

This is a naive implementation of a Z-sorting in order to fake 3D depth using sprites in a 2D scene. I would appreciate feedback on this, especially for performance as this has to be called each frame ...
2
votes
0answers
5k views

Securing Web API using token authentication and allowing external application to post or get data

Implementing OAuthAuthentication with OWIN and Identity to secure Web API and let external application like Chrome Extension to access our self hosted API for getting and posting data through our ...
2
votes
0answers
418 views

Copy directories using BackgroundWorker

I am writing an app to copy the contents of a directory to a removable drive. I'd like to know if there is a better way of structuring this. The UI layout is a ...
2
votes
0answers
436 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....
2
votes
0answers
899 views

Using iTextSharp and AddDocument/FreeReader to create a PDF document in streaming fashion

I have a directory of PDF files I want to merge into a single PDF. The number of files in the directory could be 10s, 100s, or even 1000s, so I'm trying to make sure my process is streaming as much ...
2
votes
0answers
180 views

Mersenne Prime Checker using Lucas-Lehmer Formula

Previously I created a C# script that used trial division to check to see whether or not certain Mersenne numbers were prime. Since these numbers are so big, I employed some math shortcuts to reduce ...
2
votes
0answers
162 views

Establishing a TCP connection with async & await

I'm not really super experienced async/await and working with tasks, so I thought I'd ask for some other opinions. I'm working with code written by someone else that establishes a TCP connection. It ...
2
votes
0answers
7k views

Mapping Excel columns to table columns, then processing data

I have written some code for mapping excel columns to table columns and processing data after mapping columns. Please review this code, check for SOLID, OOP principles and suggest any improvements and ...
2
votes
0answers
5k views

Blocking TCP Client with Threads vs. Non-Blocking TCP Client with Unitys Update

I'm not sure if this is the right subsite of stackexchange because it's not only about code review but a bit about design eihter. I'm currently developing a network application. I need to connect a (...
2
votes
0answers
984 views

Caching using MS Unity Interception

I wanted to cache methods using unity interception and not have the parameters passed in stay alive for the sake of caching. If the objects would have gone out of scope without caching then the cache ...
2
votes
0answers
162 views

Keep clean SimpleIoc initialization when reusing UserControl

Originally I had ChildUserControl inside ParentUserControl inside MainWindow with this view-...
2
votes
0answers
989 views

Connecting to an MS Access database (OleDB) with multiple users

I'm writing C# applications that store their data in MS Access databases, (I'd rather use a different type of database but currently have no other option). The applications are in use by multiple ...
2
votes
0answers
696 views

Custom animated image control

I have written the following control which allows loading a gif from embedded resource, file, or raw Image. It allows for more granular control over the direction ...
2
votes
0answers
487 views

Generic polling class and using it to poll SqlConnection

I have the following poller class that can be used to "poll the required action": ...
2
votes
0answers
189 views

C# Winforms MVP (avoiding circular dependencies)

I asked the following question on stackoverflow and as a result came up with the following code to avoid circular event logic when using winforms. There are two occasions where my model can be ...
2
votes
0answers
77 views

Countable and uncountable sets in .NET (set operators, demo)

Up-to-date version: IEnumerable and Predicate Sets in .NET (Complete, Explained). Previously: Countable and uncountable sets in .NET (clean version). Disclaimer: Please do not interpret my attempts ...
2
votes
0answers
232 views

Binary protocol variability V3.0

Summary: Parsing an incoming stream of events from a binary communication protocol, if we have some variations in devices to support and would not like to have one huge switch to include everything. ...
2
votes
0answers
403 views

Implementation of custom config section

i recently wrote my first custom config section. I have a collection of index files, each has a path and a savetime: ...
2
votes
0answers
2k views

Optimising looping through large data set and updating database

I have a database table storing information about documents (MigrationMaster). There is another table with security information on these (DocumentSecurity). There are 4 steps I can see that I need to ...
2
votes
0answers
190 views

Extension for BindableBase that can dispose the old value of a property if that property implements IDisposable and is not null

I am interested in hearing opinions on this. I need a way to dispose the old value of a property in a way that's compatible with BindableBase. Specifically, I have ...