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.

482 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3
votes
0answers
551 views

Hackerearth Simple Function - Follow-up

Problem statement Let us first describe a SimpleFunction: ...
3
votes
0answers
854 views

Convert date time string with non standard timezone offset in C#

I couldn't find a .NET date format type to handle dates in format I need to process, they sometimes have time zone offset with +/- prefix followed by 3 digits for the number of minutes timezone is ...
3
votes
0answers
119 views

Mesh Modifier System in the Unity Game Engine using C#

The system is meant to replicate the deformers and modifiers commonly used in 3D modeling programs like 3DS Max, Maya, Blender and Cinema 4D. I made a post on Reddit, explaining the features and ...
3
votes
0answers
2k views

Custom generic repository pattern

This weekend I made an attempt at a generic repository pattern for entity framework in .NET after reading this blog post. I was wondering how it could be better. I specifically have a couple questions....
3
votes
0answers
167 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, ...
3
votes
0answers
267 views

Asp.Net MVC Application Controller

I'm developing a webapp in ASP.Net MVC. One of the requirements of the project is that users follow a "workflow". The workflow has a number of steps, and a conditional branch. The workflow is long ...
3
votes
0answers
499 views

Deriving classes to decorate auto-generated base class code with attributes

Background: I am currently in the process of abstracting and refactoring out EF for Dapper with ...
3
votes
0answers
1k views

Solving the Mining algorithm from HackerRank

I was working on this problem for a few hours last night and finally came up with a brute-force solution. The task is to report the minimum work necessary (sum of weight × distance) to relocate gold ...
3
votes
0answers
77 views

Making recurring requests to a web service using Task.Run

I am practicing with using Tasks and I put something together but am unsure if I used it properly. I read through Stephen Cleary's blog and it seems that it is okay but at the same time I do some ...
3
votes
0answers
349 views

WPF Prism DelegateCommand Setup

I am currently in the process of learning WPF Prism and I have four buttons that I want to all go to the same place but with a different value being passed depending on which button has been pressed. ...
3
votes
0answers
327 views

CodeEval - Lucky Tickets challenge

This a solution to the CodeEval's challenge "Lucky Tickets". After a failed attempt with brute-force calculations (no surprise here), I have tried to implement an algorithm that I found on ...
3
votes
0answers
100 views

Multitenant app authorization

Role based security does not work for me well in a multitenant app, as I need to query DB to decide on permission allowance. Here is the solution I came to. All implementations of this interface will ...
3
votes
0answers
696 views

Tiny calculator using dependency injection and inversion of control

I've started to learn very interesting concept of DI, IoC and related stuff. I have decided to learn it using simple application, very tiny calculator (only basic functions: add, subtract, multiply &...
3
votes
0answers
85 views

Event delays for a Monogame project

I am making a GUI for my C# Monogame project. So since this was the first time I ever made a GUI that is not winforms-based I took a wrong approach in making it and thus I decided to change it ...
3
votes
0answers
109 views

Rbac Principal with Binding support

I've been maintaining a Rbac helper for some time now. My goal is to provide an easy way to tell the following: When does an user have a role What can a user do (...
3
votes
1answer
1k views

LINQ statements that aggregate sums from a List of objects

I'm packaging data for use in a JavaScript charting library that expects a somewhat odd structure of data in which there is an array of labels and an array of ...
3
votes
0answers
395 views

Lazy WebAPI object

I am working to design an object which would abstract away the use of a WebAPI. I want the developer to be able to use these objects as if they are using a traditional API. My core problem is how to ...
3
votes
0answers
953 views

Workaround proxy to be able to call 32-bit dll

I had a problem that I posted on StackOverflow about that I could not connect to windows phone 7 from a 64-bit application. I got one response that said I should try to create a WCF Service over named ...
3
votes
0answers
202 views

Safely aborting thrid-party code using TPL

I'm using some third-party libraries in my project. Once in a while the code in these libraries freaks out and produces infinite loops and other nasty things. My goal is to write a wrapper that allows ...
3
votes
0answers
2k views

Web API 2 - JWT with X509 certificate

I got my JWT generation working with X509 and wanted to ask if you would recommend any changes in respect to: Signing certificate storing / handling. Publishing for anonymous access public key ...
3
votes
0answers
1k views

Wrapper for jQuery Ajax to ensure redirects occur on clientside - Round 2

A while back I posted Wrapper for jquery ajax to ensure redirects occur on clientside on handling ajax and redirects when a server side error occurs. Since that post I've been using this module ...
3
votes
1answer
123 views

TimeoutManager: check whether a task has been finished within a given time

I want to make a helper class, which raises an event whenever something is not finished in a certain time. Example: my program sends out multiple network messages concurrently. After a random delay, ...
2
votes
0answers
63 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
26 views

Manage independent script component architecture in unity

I have different set of objects where I have to show Name UI and Menu UI using OnMouseDown and on OnMouseEnter. Remember Both ...
2
votes
0answers
52 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
1answer
51 views

String template using concrete implementation instead of external library

Q1: What are the benefits of using any external library e.g Antlr3.StringTemplate? Q2: What are the potential issues with the below implementation? ...
2
votes
0answers
35 views

NetMQ Actor pattern

I'm trying to have one WPF application to communicate with an other application when something change on the UI. For example : a slider changes and I send the new value or a textbox input change and I ...
2
votes
0answers
36 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
102 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
51 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
24 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
25 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
41 views

Seekable HTTP response stream wrapper

I created this wrapper to use together with HttpClient streams and ZipArchive. ZipArchive ...
2
votes
0answers
48 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
55 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
63 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
65 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
54 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
47 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
44 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
111 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
199 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 ...
2
votes
0answers
53 views

Querying based on condition

I am using Entity Framework Core as ORM in my ASP.NET Core 2.1 project. I want to perform server-side pagination in Career Controller for getting list of careers. I have a model which looks like: <...
2
votes
0answers
77 views

Making a Icosphere in C# and Unity

In Main.cs, which is attached to a GameObject that has a MeshRenderer and MeshFilter: ...
2
votes
0answers
96 views

Create an isolated dependency scope with “overrides” in Asp.Net Core

Some of the classes in my multi-tenant Asp.Net Core application depend on database repositories which in turn depend on a delegate called GetCurrentTenantKey. In ...
2
votes
0answers
128 views

WebAPI: Async Filtering CSV content + Json/XML Serialization

I am coding a csv file filtering api in ASP.NET Core, which takes a csv file located at a given uri (and retrieved via the query string) convert the content to a collection of records, then apply a ...
2
votes
0answers
61 views

Iterating in a list of data and search data in another datatable

I have a list which has 25000 data and I am iterating in all data and in each iteration, I am searching data in another data table. my whole routine is taking a long time to finish. Loading data from ...
2
votes
0answers
84 views

Web API CRUD Demo with Console App and MVC Web Application

I have created a simple CRUD method using Web API project which consumed by 2 platform: Console App and MVC Web Application. The EntityModel project is mainly the entity and the DAL layer. Is my ...
2
votes
0answers
65 views

Generic DialogueBox class with different parameters

I have implemented a DialogueBox class which can be static, singleton, service locator, etc. I have written it as a singleton pattern and implemented it in Unity3d engine. It is a part of a game. I ...
2
votes
0answers
44 views

VSTO add-in for Excel to solve systems of linear equations

This code is part of a VSTO add-in for Excel. As the title states it solves systems of linear equations by allowing the user to select the appropriate ranges. The code works and covers most issues I ...