Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [c#]

C# is a multi-paradigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform.

0
votes
0answers
5 views

Simplified light Serialize/Deserialize to/from JSON for .NET

Just a very simplified and stright-forward way of serialize/deserialize to/from JSON using standard .NET 4+ libs. I was trying to avoid "complexity", so get rid of 3rd part libs and heavy-...
1
vote
1answer
49 views

Assigning values to array elements based on a look up table

HI i am writing a c# program where i need to populate a array based on a look up table and set of string arrays with metadata. My lookup table looks like this (Table with key: transmitter, value: ...
2
votes
0answers
33 views

Straightforward tax calculator OO design

This question has been asked here before and my solution is pretty much in line with some of the answers to the question to this question. I wanted to work on this a bit. Scenario Basic sales ...
5
votes
0answers
38 views

Rendering tree of nodes as string

I'm creating a debug-view for my expression-trees. They record each operation automatically in a tree that I am transforming into string so that I can see the exact ...
0
votes
0answers
32 views

OOP 2D racing game using the graphics component in WPF [on hold]

I just recently created a 2D racing game using the graphic component in Windows form application, my main concern is that the application, even though is made of classes, is not following the ...
1
vote
0answers
59 views

Putting a Queue Between HTTP Request/Response

We currently have two legacy systems: the Consumer and the Worker. These systems are massively complex in ways that are not important to this review, but it is enough to say that a large-scale re-...
0
votes
1answer
71 views

Different payment details in a common list, to be casted [on hold]

I need to be able to access a number of different payment methods in a common list. They can be different methods - credit card, cheque, direct debit etc. The only common attributes are the payment ...
0
votes
0answers
16 views

feedback needed on c# data access library for mongodb [on hold]

i just pushed out v3.1 of MongoDAL which is a simplified data access layer wrapped around the mongodb c# driver. the api is quite easy to use compared to the official driver. an example query would ...
2
votes
1answer
54 views

Parse through an XDocument efficiently and match values to matching object

Minimum viable test program: ...
0
votes
1answer
68 views

Generically call static methods

I currently have two (core) classes : ...
5
votes
2answers
63 views

Unmanaged byte array to managed structure

I have a need to turn byte arrays into various structures. First version: ...
4
votes
1answer
55 views

Asp.net networking/restclient layer

I have been working on creating maintainable networking layer for our Asp.Net Core Web Api project. Right now I have created Generic methods for Get, Post, Put like this. ...
-2
votes
0answers
30 views

Refactor code to comply DRY pattern [on hold]

I have bunch of if's in my console app, which check if command line parameters are valid, it all looks like this: ...
3
votes
1answer
84 views

Generating Biased Random Values (Walker's Alias Method)

Am simply wondering if I made any egregious mistakes while implementing the Alias Method as an IEnumerator<TElement>; would also like to know if there are any ...
-5
votes
0answers
17 views

File is exist but dowload code gives FileNotFoundException error [closed]

I want the user to download docx. documents from the website. ...
0
votes
1answer
47 views

LINQ or Lambda for two foreach query [on hold]

I have a Document Name Table in my SQL database and Files in the Content folder. I have two lists: ListOfFileNamesSavedInTheDB and ...
3
votes
1answer
58 views

LeetCode gas station implementation

There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i ...
3
votes
3answers
141 views

two integers one line calculator

I created this simple one line calculator for two numbers only where user can input any two numbers and and operator in between for example 20+45 and computer will return result of 65. ...
3
votes
3answers
88 views

Cooking steak with State Pattern and without IFs

I've been playing around a bit with a case of State Pattern but including as well ranges in order to get into a specific state. So the definition is as simple as this: There is a Steak that has a ...
4
votes
1answer
65 views

Unit testing extension method adding view location expander

Introduction I'm writing unit tests for an extension method I wrote. Its only purpose it is to wrap startup logic which extends ViewLocationExpanders list by an ...
1
vote
0answers
69 views
+50

Persist payload containing multiple items using EF Core Performance Improvements

I have an .NET Core EF application, setup as Database first, that is supposed to take in a payload containing items to be persisted to my database. They payloads can be huge containing multiple "...
-2
votes
1answer
68 views

Cleanest way to get value from secondary form [closed]

I've written a simple program that reads barcodes from a page and will ask the user to select one to use. I have a few methods that use the results of that form and I was wondering if there is a ...
2
votes
0answers
64 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 ...
1
vote
1answer
49 views

ASP.net service that sends email whenever an entity is updated [closed]

I have an ASP.net MVC5 project which involve different domain services, and one of it are EmailService which will send email if entity is updated. ...
2
votes
0answers
39 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
36 views

Limit concurrent calls per period in C#

I have an external API which is rate limited, so I can call it only 50 times per second with the same auth token. I have many auth tokens, so I need throttling per auth token, which will not allow me ...
2
votes
1answer
49 views

Polymorphic DBConnector class exercise

GitHub GitHub if it's easier I'm in the process of doing a training course in C#. I've just gone over covering Polymorphic OOP / composition over inheritance etc... The latest exercise I completed ...
5
votes
1answer
97 views

Simple File Manager with recursion in C#

Simple class to simpify runtime file loading of ressources. The class reads all files from a given directory including all subdirectories and stores the name together with the path in a simple struct. ...
2
votes
1answer
82 views

Stopwatch exercise from training course

Github Github for easy testing I'm currently undertaking a training course to try & further develop my skills in C#. The latest exercise was to create a basic stopwatch class that meets the ...
4
votes
0answers
116 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 ...
1
vote
2answers
105 views

Leetcode: Roman digit to integer

I tried to solve the question at https://leetcode.com/problems/roman-to-integer/ i.e Converting an Roman Digit to a Integer using C#. It passes all the test cases but any suggestions to reduce run ...
3
votes
0answers
49 views

Converting VBA Add-In to C# VSTO. Code following button click event

This is my first program with C# and VS and was originally a VBA Add-In I wrote. I have embarked on this as a learning exercise. The code does work and provides the desired output in a new workbook. ...
2
votes
0answers
39 views

REST API request automation [closed]

I created a class to automate some requests for an API. Can I improve this code in any way? The code itself is very simple and easy to understand. ...
4
votes
2answers
64 views

Database Model Security For Book Inventory

This code is one of the models developed for the Book Inventory application that is open for review. It is also based on a comment on this answer to a C# question. Based on the comment I did some ...
2
votes
1answer
87 views

C# Login Form, Login Button , security

So, I am new to VS and C#, I am self-teaching to get a better understanding of the back-end of the product I work with. I have created a small database with some information and a Login form. ...
8
votes
3answers
116 views

Convert human readable string to TimeSpan

I want to pass time interval as a string (to program args) and then I want to parse it to TimeSpan. I created simple class: ...
3
votes
3answers
79 views

Reordering items which must have alphabetically ordered keys

I have a list of objects each with a unique Key and a display name (Label). The list needs to remain sorted by the keys of each ...
2
votes
1answer
75 views

Web Server handler class to pass IIS http requests to SQL Server stored procedures

This is a c# class I use to implement web database applications with Microsoft IIS and Microsoft SQL server. It passes the http context to a selected SQL stored procedure, and writes a response based ...
2
votes
0answers
15 views

/Proc/net/tcp results Converter/Editor

Being unable to easily read the output of /proc/net/tcp I made a small C# console app that modifies the output to be in decimal notation instead of the standard hexadecimal, show the corresponding ...
1
vote
0answers
30 views

Querying connection string across solution [closed]

I have an app.config file that contains some connection strings, this is accessed on a project-by-project basis In my solution, I have the following projects: A B ...
2
votes
1answer
66 views

.NET Custom hierarchical expression to treeview data structure

I'm not good at English. It's gonna be hard to read. I apologize in advance. I need expression parser for draw diagram(fault tree). In order to do that I have to create data structure from ...
2
votes
1answer
86 views

Using Dictionary of int and list of tuple in C#

I have implemented mathematical functions using a C# library. I basically need to output data by the RiskMatrixByFunds in the following format. Key will contain Id ...
1
vote
0answers
44 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. ...
1
vote
1answer
85 views

IEnumerable<T> async serialization

I am building some classes to serialize (in an async / await way) potentially pretty long ...
4
votes
1answer
182 views

Best way to performance permutations

This has been my white whale for a while, the idea is convert all the symbols to the goal symbol using all the pieces. I did an algorithm like 5 years ago (now is lost) and reach lvl 48 but got stuck ...
-3
votes
0answers
26 views

Covariance and Contravariance related understanding the point and architecture [migrated]

First of all apologize for long post nevertheless i wanted to highlight problem exactly and to be most readable and understandably. I am developing architecture of my program which will be responsible ...
3
votes
1answer
70 views

Implementation of Strategy Pattern (photo gallery example) [closed]

I'm learning design patterns and I thought that it would be a good idea to make my examples of each pattern. This is my example of the Strategy Pattern. Can you tell me is it good and what to improve? ...
2
votes
2answers
123 views

Consecutive words match in a dataset

I have written an algorithm to do consecutive word match in a dataset The input is a dataset (list of textlines) and I want to scan that and return repeated word(s)...
5
votes
1answer
70 views

C# asynchronous notification vector

The purpose of this class is to efficiently notify another thread when data is available with minimal blocking to access/pass the data. The data reader/producer thread processes data in bulk which ...
2
votes
1answer
114 views

Generic UnitOfWork

I am trying to create a Repository & UnitOfWork for Data Access Layer. In my current implementation I have to modify my UnitOfWork everytime I create a new repository. I would like to avoid that ...