Stack Exchange Network

Stack Exchange network consists of 174 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
1answer
44 views

Grouping report data by one of two criteria

I have a report with a group by filter. A stored procedure returns all the data and maps it to IEnumerable<EventListRow>. The code should then group the data ...
4
votes
1answer
42 views

Comparing similar types that don't share any interface

I have two types that don't share any interface but have similar properties and that I need to compare for equality. One of them is comming from a 3rd party library and one of them is mine. I ...
1
vote
1answer
33 views

Flip coin Game in an Object oriented way

I started out creating a simple game in an Object Oriented way to practice. The rules are pretty simple There are two players You let one player choose if they want Heads or Tails. You assign the ...
0
votes
0answers
26 views

Error-Handling Class and Logging

I am relatively new to C# and would like to see if what I have been using for my exception handling, message and logging is along industry standards. I have created a simple class for the Error ...
0
votes
0answers
22 views

EF core 2 generic repository implementation

EDIT: If you're against a generic Repo Can you show me another method to implement these abstractions to adhere to AOP and SOLID principles besides a generic repo? I'm implementing a generic repo for ...
-4
votes
0answers
13 views

How can I make this function run asynchronously? [on hold]

This function runs thousands of times on different files, causing the UI thread to lock up. It gets called in several different places in the program. How can I make it run asynchronously? The issue ...
0
votes
0answers
17 views

Refreshable JSON settings file accessible for HttpClient provided by IHttpClientFactory

I'm trying to achieve the functionality of automatically reloaded JSON settings file and at the same time maintaining all the benefits of using IHttpClientFactory (...
2
votes
0answers
23 views

Binary heap implementation with a generic base class

This is my attempt at implementing a Binary heap. I made an abstract base class Heap with an abstract property controlling whether it is a min-heap or a max-heap. ...
1
vote
2answers
29 views

Continuous Shuffler with “linked loop”

As an academic exercise, I decided to implement a continuous shuffler, as seen on casino blackjack tables. It operates by storing a "linked loop" (a linked list with the last element linked to the ...
2
votes
2answers
45 views

Collect members from custom tree nodes

In my program, I have a tree of Group nodes, each identified by their ImportId. Each group has zero or more members, that I ...
1
vote
2answers
102 views

Bubble and Cocktail sort

Lately, I've been developing sorting algorithms as a kind of exercise to make better code and I've come accross something curious, even though bubble and cocktail sort are known to perform horribly, I ...
-1
votes
1answer
39 views

Pramp: Flatten a Dictionary skipping empty keys

This is a question from pramp: A dictionary is a type of data structure that is supported natively in all major interpreted languages such as JavaScript, Python, Ruby and PHP, where it’s known ...
-1
votes
0answers
20 views

Getting a real time data on TCP Server from UWP [on hold]

This is a method that sends the data to TCP server. ...
2
votes
1answer
44 views

Product and Factor

Overview I was challenged recently to write some code that could find the smallest integer that when multiplied and divided by 2 or 3, retained all of its digits and gained no extras. For example: ...
-2
votes
0answers
48 views

Select single result from Join linq Query in a better way [on hold]

First time I ask something here instead of Overflow, so sorry if I do something wrong. I have three objects related to each other : Product, Characteristic, Value. A product can have multiple ...
4
votes
2answers
82 views

Tic Tac Toe with images

This is my first 'real' project in C# , i looked up some tutorials on the Internet for Tic Tac Toe. But they were not how i wanted it to be, so i came up with some own ideas and wanted some tips on ...
7
votes
3answers
2k views

Add multiples of 3 or 5 below 1000, Can this code be optimised. Project Euler #1

I have seen some solution here for the same problem, this and this I have found better ways to solve this problem. I just want to know how good or bad my code and way of approaching this problem is. <...
-4
votes
0answers
70 views

Which Pattern is Better for Checking Conditions? [on hold]

In most of the methods I write, Especially methods for APIs, I have to check some conditions and then return messages. in general, I can think of two coding styles and patterns to do so. Pattern 1: ...
-3
votes
0answers
25 views

How can i write a regular expression for both “Range: [ > 20 ] and [ < 30 ]” and “Range: [ >= 20 ] and [ <= 30 ]” in c# [closed]

How can i write a regular expression for both "Range: [ > 20 ] and [ < 30 ]" and "Range: [ >= 20 ] and [ <= 30 ]" string as a single regular expression.
1
vote
0answers
35 views

Max number of concurrent tasks in asp.net [on hold]

Background I have a highly available asp.net (4.5.2) web api receiving very high load. The app primarily reads from a Redis cluster, processes/formats the data & returns in json or protobuf. Due ...
-4
votes
0answers
46 views

How to merge two List<T> and remove one duplicate column value [closed]

I have a scenario like below Model: ...
1
vote
1answer
82 views

Quicksort Without Recursion

Am teaching myself about sorting techniques and trying my hand at a quicksort implementation. I found a lot of examples based on recursion but didn't want to go that route in a language that doesn't ...
1
vote
2answers
98 views

Luhn Algorithm “modulus 10” checksum

I wanted to challenge myself in a new language that I am learning (C#) by doing a simple exercise: check if a "modulus 10" Luhn number is valid or not. In this case the common application if verifying ...
1
vote
1answer
108 views

TicTacToe game in C#

I have been studying C#, and I am trying to model the Tic Tac Toe game. Is my program reasonable or is there anything I need to improve? ...
-2
votes
1answer
47 views

Simple calculator with validation [closed]

I've implemented a simple calculator in C# that takes in the left operand, the operator, and the right operand. Once the calculate button is clicked, I use four methods to validate the inputs: 1. The ...
0
votes
3answers
95 views

Extracting information from JSON

Here is a simplified version of my JSON. ...
-2
votes
0answers
32 views

#if DEBUG and the correct ways to implement it [closed]

I wonder what I should do in a situation given in the following example: I built a condition, based on the preprocessor directive #if DEBUG. SonarQube says that the code never executes, but this is ...
0
votes
0answers
28 views

users' access to windows form and record editing etc. identification

I am accessing user rights with the following code snippet. In line with these defined rights, I am trying to ensure that the form can be opened, and the process is executed according to the rights of ...
1
vote
1answer
95 views

Remove all duplicated elements in a single list

I am learning algorithms. And my current algorithm is create a single list, and try to remove all duplicated elements in a sorted list. Ex: given Input: 1 -> 1 -> 1 -> 2 -> 2 -> 3 -> 5 -> 5 -> 7 ...
3
votes
2answers
87 views

Unit testing a generic interface: proposal to avoid test duplication for different generic types

I'm looking for feedback on a way to avoid massive code duplication on unit tests of a generic interface. It is expected that the interface will have several dozen implementations with common ...
1
vote
0answers
15 views

Unity Multiplayer Authoritarian Client-Server

I have created a client-server system which handles multiplayer for a game I've been making with Unity. Problem is, it feels very clunky and complex and I want to know how the design could be ...
2
votes
2answers
44 views

Get attribute values with LINQ to XML

I'm pulling the values from the following XML based on the attribute name. ...
-2
votes
0answers
34 views

UserContext Roles search and replace, search [closed]

UserContext contains single or multiple group. ...
1
vote
1answer
102 views

NumberGuessGame

I've already posted a first attempt on Code review. Here is a new version that takes into account the answers I've received. Is my program now reasonable or are there still things I need to improve? ...
7
votes
4answers
374 views

Binary Heap (list-based)

This is my first attempt at implementing a heap data structure and I've decided to cover the methods Peek, Pop, ...
4
votes
2answers
92 views

Find minimum XOR values in a given array

I am implementing an algorithm to find the pair of integers in the given array which have minimum XOR value. Ex: Input: 0 2 5 7 Output: ...
4
votes
2answers
53 views

Initializing multiple variables with different types using parallel calls

Consider the pattern below, where multiple async calls are made in parallel: ...
3
votes
1answer
46 views

Guess that number, Larger or Smaller?

I created a simple guessing game for the sake of practice, it's been a while since I've had any code reviewed. I do have a tendency to over-engineer things sometimes and I'm not typically aware of it ...
3
votes
3answers
238 views

Get collection of objects from CSV string and vise-versa

A generic class to get object collection from csv string. I would like to know if there's any better way? Converter class ...
3
votes
1answer
93 views

Simple application to look up items in a list

I'm very new to the programming world and have been working exclusively with console window applications in C# thus far. I've created a program which took me way too long to produce but I'm very proud ...
3
votes
1answer
49 views

Determining if there is data left after fetching a page of data

I just faced a problem where I needed to know if extra data was present in a given collection after a Take operation took place. Specifically, this is related to ...
-4
votes
1answer
48 views

Try method pattern [closed]

when reviewing, sometimes I see methods like: ...
3
votes
1answer
69 views

Snake Game Library for WPF

Recently, I had a sick leave and to had some fun and improve coding skills I got a challenge to write a Snake Game for WPF. Desired RESULT 1) Game must be in separate .dll library; 2) Must have ...
2
votes
3answers
123 views

Simple random number guessing game with various difficulties

I have been studying C#, and I am trying to model the Random number guessing game. 1 User inputs the number of try. 2 Computer generates random number. 3 If numbers doesn't match user lose one try ...
6
votes
2answers
86 views

Validating user input for the game of draughts/checkers

I'm trying to script a C# game of Draughts/Checkers. I'm at the point of taking user input and validating it. I first check the input of current x and y coords to see they are numbers, then check the ...
-2
votes
0answers
53 views

Learning MVVM, am I on the right path? [closed]

So I started learning MVVM a couple of weeks ago and I am really scared / afraid that I've been reading up on the wrong things. The code runs just fine but I was told that there was a lot of issues ...
6
votes
1answer
51 views

Monadic list for a more functional approach to C#

I am learning about monadic structures and have created a sort of monad list that implements the map and binding "operators" (or technically methods) in C#. I understand that Linq already exists and ...
0
votes
1answer
55 views

Tycoon-style Idle game

I am creating an Idle game right now (tycoon style) which has 9 trains, (8 of them needed to be purchased), and 1 is always active, no matter if you just started the game. I was trying to create a ...
3
votes
2answers
96 views

Calculating a Luhn Check Digit

I was able to find all kinds of examples that demonstrate how to validate a Luhn Checksum but very few that actually generated the check digit. Here is my attempt based on the validation examples ...
7
votes
5answers
1k views

RockPaperScissor Game

I have been studying C#, and I am trying to model the "Rock / Paper / Scissors" game. Is my program reasonable or is there anything I need to improve? user input a round. user input RockPaper or ...