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.

695 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
0answers
147 views

Fnv1a hashing of C# Guid

I have the following implementation of the Fnv1a hashing for a string, which should be correct: ...
2
votes
0answers
36 views

C# MySQL library: How can I reduce bundling and abstraction?

I'm a teen developer who just does this as a hobby, but I still care about good practice even if I don't fully understand it. Two of the most used phrases when sharing the code of my C# MySQL library ...
2
votes
0answers
102 views

ASP.NET Core 3.1 Multi-tenant with separate database

I am following this sample by Gunnar Peipman to create a multi-tenant architecture in my ASP.NET Core 3.1 application. It is working as expected up to the point shown in the sample. ...
2
votes
0answers
87 views

Marching Square algorithm

The following source code is a solution to the Marching Square problem. The explanation of using random numbers in ambiguous cases can be found here. ...
2
votes
0answers
501 views

C# Color implementation with conversions from RGB to HSL and CMYK and vice versa, targetting Blazor and CSS

This is an implementation of a Color class, primarily targetting the web to be used in a Blazor app. Color.cs ...
2
votes
0answers
31 views

Uploading CV file to an e-commerce website and sending the CV to employer's email

I am working on an e-commerce website. In this specific scenario, people can upload their CV to apply for a job. The job application is sent to ApplyForJob action ...
2
votes
0answers
120 views

Making 90% similar code for 20 different objects

Basically, I have 20 very similar objects and most importantly I want to do the same thing for all of them. This is the ImportProcessor class for ...
2
votes
0answers
64 views

Building a string with only two repeating characters (different code)

Context I would like to receive feedback on my code for the question which can be seen here. Problem This is another C# implementation for the a function for given parameters ...
2
votes
0answers
55 views

Managing invalid cookie when 2 users use the same computer and therefore share the same cookie

I have asked this question on stackoverflow... here, I am asking for some feedback on the solution that I have implemented. I am using ASP.NET MVC default template to logout user: ...
2
votes
0answers
71 views

I'm just starting out with tasks. I need to know if there's a better way to do TAP for socket handling (serving a request)

I've got this quick and dirty little console app in C# to serve an HTTP/HTML page. ...
2
votes
0answers
22 views

Is this way of handling events in a Xamarin project memory safe?

I inherited a Xamarin project and I'm trying to find my way. The first task I completed involved creating a new reusable view and adding it to an existing screen. This was iOS specific, so I went and ...
2
votes
0answers
91 views

Trie to index files and search for them

Basic idea (foo and foa are filenames): ...
2
votes
0answers
36 views

Basic login by username logic with SQL Server

My goal is to make a very simple library with the authentications basics: create a user and save its hashed password, change its password, have a method to check if the password is correct for login. ...
2
votes
0answers
30 views

How to best structure an abstract class where a member field will depend on the deriving type?

Puts and calls are two types of options. One parameter that they both share is called a strike price. The valuation of an option is related to the strike price, but the exact methodology is different ...
2
votes
0answers
545 views

C# class to dump the memory of a process in several formats

I made this because I couldn't find any good C# classes/libraries that allow you to dump the contents of a process' memory into a file or a byte array. I haven't tested this on 32 bit systems but it ...
2
votes
0answers
433 views

How to efficiently execute multiple async calls in parallel to cassandra in C#?

I am working with Cassandra where I am getting some stuff out of it using Datastax C# driver. Below is my code which interacts with Cassandra db and in my ...
2
votes
0answers
38 views

Email Service - Sending an email with azure blob storage Version 2.0

Now implemented changes suggested in my previous post and now am back again for the internet to tear me and my shitty code down. PatchNotes Extracted templateRetriever class from the email service ...
2
votes
0answers
42 views

Reactive .NET retry policy

I haven't found a good code example for a reactive retry operator with a retry strategy that was good enough for my needs. So I tried to make my own. It seems to work in my tests but I would really ...
2
votes
0answers
1k views

Uploading files through streaming with SignalR

I want to upload files from my Javascript client to my WebAPI. With this I want to have a progress bar. My Idea was to cut the files up in chunks and then stream them via SingalR since we are using ...
2
votes
0answers
47 views

Sharing model for different ORM's

I am building a MySQL to Realmdb converter app. I use Entity Framework to deal with MySQL, so below is the code of one of my model classes. I don't want to have multiple classes representing the same ...
2
votes
0answers
57 views

Mapping an object tree to another object tree

Programming to an interface is a design principle that enhances the flexibility of software by hiding implementation details. Consider an object tree that only exposes an interface, but you want to ...
2
votes
0answers
27 views

Web API wrapper design and sharing EF database context

I'm trying to keep my sanity while working with a legacy winforms application that uses an web api, both maintained by my team. In the past we have multiple cases of methods using wrong api endpoints,...
2
votes
0answers
38 views

API Layer ClientId and Security style

Im at the point where I am designing my api security and I was going with a custom attribute I don't want to use third party systems as they cost money. I was going to use the client id and the ...
2
votes
0answers
335 views

Java's AtomicInteger equivalent in c#

I'm trying to replicate Android's GenerateViewId() to assign a unique Tag to dynamically created UIViews in Xamarin.iOS. ...
2
votes
0answers
44 views

Task scheduling

A simple design for task scheduling using the following classes/interfaces. ...
2
votes
0answers
82 views

Testable random number generator

Here is a custom Random<T> class which could be used as: ...
2
votes
0answers
74 views

Generic search service to filter entries in lists

I'm in the process of implementing a fully generic service to filter out entries (of any type), which are contained in a ICollection. As it is generic, without any ...
2
votes
0answers
755 views

Reactive Extensions wrapper around Confluent.Kafka for .NET

Just an Rx wrapper around Kafka to represent topic consumption as IObservable<T>: ...
2
votes
0answers
2k views

Accurately measure ASP.NET Core 3.x actions execution times (Web API project)?

I want to be able to log the time spent by a certain Web API action in an ASP.NET Core 3.x application. This is a very old question from ASP.NET which relies on global action filters, but in ASP.NET ...
2
votes
0answers
140 views

Unity rotator script

I was playing around with Unity's new Entity Component System and I was trying to implement a rotator system. This is what I came up with: Component Data: ...
2
votes
0answers
94 views

LINQ extensions for sequence comparing

The desired behavior would be: ...
2
votes
0answers
343 views

Web API get data with many optional parameter in .NET Core

I would like to do a refactoring of web API implemented in .NET Core. The Goal is to simplify ...
2
votes
0answers
85 views

Execute asynchronous read in parallel

I found it useful to execute multiple reads in parallel using a set of my extension methods for TaskFactory, which could be used as: ...
2
votes
0answers
55 views

Unit testing the code that is written using repository pattern

I have implemented my business logic using the repository pattern. I have an Approve method in my controller. I am calling the service method ...
2
votes
0answers
73 views

Retry HttpClient request without handlers

I have a server and client application. In the client application, there are HttpRequestException class exceptions on requests. As it seems to me - these exceptions happen in isolated cases and not ...
2
votes
0answers
125 views

Access a variable after several references

I have a team lead that used to write references in a single script then access it in every script. Like for accessing a variable he has to write code in this way ...
2
votes
0answers
114 views

Concurrent execution and coordination of C# tasks

I have a class, 'TaskCoordinator' which has 'BaseTask's applied to it. The BaseTasks have OnStarted, OnFinished and OnCancelled events which are triggered to notify the calling class of their events....
2
votes
0answers
26 views

Initializing Group Data Mess

This is my OnAppearingAsync method where I as a page load in Xamarin I filter data, group it together, set data based on it, order the groups e.t.c. However the code is rather long and looks a bit ...
2
votes
0answers
36 views

File and folder filter for a "last-updated explorer"

Sometimes I save a file somewhere but can't find it after or I install something and want to see what files were added. For this reason, I created a winforms app which only displayes files created/...
2
votes
0answers
578 views

Seekable HTTP response stream wrapper

I created this wrapper to use together with HttpClient streams and ZipArchive. ZipArchive ...
2
votes
0answers
75 views

Implementation of SCPI for control of test instruments

I work with electronics test equipment. I like to be able to automate tests using their remote control interfaces. I have built a pattern, a few base classes, that I can apply to all devices that ...
2
votes
0answers
60 views

Function to match the case of a text as per another text

I am translating a text into another language using Google APIs. Sometimes the translated text returned from the API does not match the case of the text provided - e.g. when translating the text "...
2
votes
0answers
377 views

Stream JSON from Azure Cosmos DB to browser in Web API

I have an HTTP endpoint for returning data directly from Azure Cosmos DB. The endpoint is basically a database access point (this seems like a common case). Since I'm returning the data unmodified, ...
2
votes
0answers
148 views

LeetCode: House Robber II C#

https://leetcode.com/problems/house-robber-ii/ You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place ...
2
votes
0answers
93 views

Own Authorization attribute

In the existing system, we need to rebuild the user's authorization. The database includes Roles and Rights Roles were previously used but will be skipped in the new version All authorization will ...
2
votes
0answers
102 views

Managed Vulkan API Wrapper (create/destroy an instance)

I'm trying to follow this Vulkan API tutorial and have come up with an implementation that I don't completely loathe. The VkUtf8StringArray class is my least ...
2
votes
0answers
353 views

LeetCode: trapping rain water C#

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. The above elevation map is represented by array [...
2
votes
0answers
57 views

Retrieve file and other input fields from JavaScript to send to ASP.NET Core

I am currently developing an e-commerce website where users can upload their photos to customise their products. The use case begins when the user selects a product from our website (e.g. shirt). ...
2
votes
0answers
690 views

Frog Jump time complexity

I have tried to work out the Frog Jump task on Codility. The algorithm for solving this is rather simple but the maximum score I am able to achieve is 55% (also 44% with modulus operations). A ...
2
votes
0answers
791 views

Ninject binding for Dbcontext

I have an asp.net web API and I am using EF6 to connect to a third party rest API which sells online game codes. We made a deal with the company so clients have to call my rest API in order to get the ...

1
3 4
5
6 7
14