# 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.

8,996 questions
Filter by
Sorted by
Tagged with
85 views

Short and sweet... I wrote a cross-thread method that displays the countdown [in seconds] of a delay on a label. I'm fairly confident it's far from optimal, so I'm in need of that glorious ...
22 views

### Android - Running endless code in Foreground while using the app

Im making an application that i want to have the ability to send report emails with a frequency. daily, weekly or monthly. Now i want those emails to be sent only if the app is running and if the ...
141 views

### Simple simulation of animals eating other animals

I was given the exercise of refactoring the following code, thus ensuring it was following the SOLID design principles. It refers to an Animal Park, where there are a couple of different species of ...
92 views

### LeetCode: Network Delay Time Dijkstra's Algorithm C#

https://leetcode.com/problems/network-delay-time/ There are N network nodes, labelled 1 to N. Given times, a list of travel times as directed edges times[i] = (u, v, w), where u is the ...
203 views

### All your Base - Exercism.io

This is an exercise on the website Exercism. I am self taught trying to learn C# and C++. This is the information from the readme. Convert a number, represented as a sequence of digits in one base,...
74 views

### Solving a linear system with two variables

Background: Equation 1: 2x-y=6 Equation 2: 4x+3y=22 Because 1 is ax-by=c and 2 is dx-ey=f y=(a * f - c * d) / (a * e - b * d) and x is simply (c - (b * y)) / a) What I am trying to do: ...
53 views

### LeetCode: Network Delay Time DFS solution C#

https://leetcode.com/problems/network-delay-time/ There are N network nodes, labelled 1 to N. Given times, a list of travel times as directed edges times[i] = (u, v, w), where u is the ...
64 views

### Propagation in grid

Can I do it with a lower Big O / better code? How can I improve this solution? Task: Let's assume we have a array like this: 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 ...
1k views

### Reverse each number in a list

I have this method which reverses a list of numbers. For example, if the given input is { 1232, 3455, 6071 }, it will return ...
72 views

### Big O notation for Reverse String

I have here some methods which reverse string characters. Example if given string is "HELLO", it will returns "OLLEH". Are my big o notation for these approaches correct? And which approach is the ...
111 views

...
263 views

### CompressSearch algorithm

I Rewrote all code, aimed at a variable reduction, and reduced complexity. removed all extraneous code unnecessary to the operation, reduced indexing surfaces, tests all work consistently. Added ...
58 views

### C# - Reapply the manipulation of JS Object in .Net Core

IMPORTANT: I made another version with some improvements: Version 2 Since some months ago I disagree with the native/code methods to manipulate dynamic or ...
68 views

### Randomly generating a WoW Classic character

Full code can be found on my GitHub but more details are included here. I decided I'd like to level up some new characters on WoW Classic & I thought it would be fun if I randomly generated some ...
63 views

### Storing and calculating extremely large/small numbers in C# using a Scientific Notation struct

I've been working on an incremental game that I will need to store extremely large scientific numbers. as a part of this game, precision is only important for numbers within similar magnitudes. If a ...
58 views

### C# - What should I do with empty if-brackets? [closed]

I've ended up with some pretty ugly code while doing some bitmasking: ...
119 views

### c# Checking if string is HtmlDecode [closed]

I have this string that I am sometimes double encoding it because it is coming from two different fields. I have build this method that will do a string StringComparison. It seems complicated wanted ...
50 views

### Decoupling of validation and data access in ASP.NET

I've been asigned to a project no dev has touched in a long time. It's an ASP.NET MVC 4 application. It appeared to be well coded, but had no testing and the database migration folder is not present. ...
46 views

### Checkout Process for Xamarin E commerce application

I'm new to development (I'm self Taught I got a job recently as an"app Developer") and this is my first real big project. In essence, it's an e-commerce store that uses a very awkward API. My Checkout ...
58 views

### Three-way join in Entity Framework Core to retrieve all roles that a user has

I'm very new to Entity Framework Core, so I'm concerned about whether I've done this query in the most efficient way possible. The database I'm querying looks like this: Basically, ...
91 views

### C# calculate total time worked with TimeSpan [closed]

So there is an existing codebase which calculates the total time worked per month. What the code is doing: iterates through all the working days entries retreives the value of net work time which is ...
59 views

### Parsing csv tokens as doubles and identifying which threw FormatException

Problem Statement I'm reading each line from a .csv file and parsing each comma-delimited value and casting it to the appropriate type: ...
59 views

### Invoicing - calling multiple pages of Api and concatinating the results

I have the following code: It works completely as expected, but I feel there is a better way to refactor it out. The flow is as follows: Call the end point with 1 page Get the total number of ...
62 views

### Prioritizing one column over the other column of the same table [closed]

I am creating an API in .net core and I just could not figure out how to put the following Linq expression into a single call: ...
91 views

### A common class for Client and Server [closed]

I have written this code to use TcpClient both from a client program and a server program. Can you review this source code? Kindly, take a close look at ...
31 views

### Handle login method with external users and LDAP users

I'm working with a ASP.NET Core (v2.2) Web Api project and implemented some APIs. However, I'm facing performance issues, hence trying to optimizing the code. Here is the login API code. ...
1k views

### Generic Heap Implementation in C#

This has been done a thousand times on here already, but here's another binary heap implementation. The implementation is generic in terms of heap elements, allows for injection of any type of ...
83 views

### Averaging students' scores

I'm still a beginner, so I'm still learning. I'm trying to take test scores for 3 different students, enter them in an array, then display the name, test scores and the average. Trying to also have ...
54 views

### Copy a C# list into an out Parameter for better encapsulation [closed]

I have a class that needs to provide access to an internal List<int> member. The functions that use this class need to be able to work with that list, ...
70 views

### Programmatically getting the GUID of an application

Intrigued by the events chronicled here (also here and here), I saw the inherent utility in having a program-specific GUID available. The SO answers that were correct seemed a bit tightly-coupled and ...
58 views

### Check source contain replace string

I created this function it is looking for the html tag and replacing it with the ^value. It seems complicated wanted to know if there is a better way to do something like this. Will you review ...
63 views

### Beginner programmer on sending error messages [closed]

I am looking to optimize one function that returns error messages to the user. ...
70 views

### Parsing CSV header for validation [closed]

I have a simple application that reads a couple of csv files and outputs the input into catalogues for the website. However, users have a habit of opening the csv files and inserting extra columns ...
81 views

### Simple c# MemoryCache mechanism to reduce number of db calls

I have some legacy code which gets a list of Students and their corresponding School. It's LinqToSql and there is no lazy ...
139 views

### Algorithm movie ticket booking

Just for fun and practice purpose, I have written a short program in C# console with few classes which will create 30 seats for a cinema during program initialization with these options. Print all ...
55 views

Context The main goal located a configuration NavigationService and NavigationView in one place. In order to minimalization a ...
76 views

### Getting names/values of multiple properties [closed]

Lets say I have one method, which extracts property name and value: ...
105 views

...
197 views

### Export sql data to xml and csv

I have the below code that takes the sql data and exports it to xml or csv. The xml is processing at good speed but my csv sometimes takes 1 hour depending on how many data rows it exports. My ...
25 views

### Entry Validation in Xamarin Forms

I have an Entry that I want to give a red outline when the entry is empty. I'm using SyncFusion's SFTextInputLayout for my Entry and it has a property "HasError" that once it's set to true, it'll ...
34 views

### Simple Unity program for a research experiment

I'm developing a small C# Unity application to display stereoscopic images as part of a wider research study. Since the experiment consists of unique stages (Start, during a trial, between trials, ...
38 views

A simple design for task scheduling using the following classes/interfaces. ...
49 views

There has been ongoing concern about the question of awaiting a task that could possibly be null, as when using null-coalescing operators. Consider the following: ...
40 views

### detecting isolated voxel-blob in 3D cube with breadth first search

I just recently got into c# and Unity coding, and would like to put this algorithm and code up for review to check how I'm doing. I've only been working by myself, so it would be interesting to hear ...
28 views

### Azure's service bus queue handler

I'm using azure's service bus in order to make orders using a IOrderLogicService interface. The Logger.InsertLog is irrelevant ...
58 views

### WPF: An implementation of INotifyDataErrorInfo

An abstract base class which derives from the ObservableObject (MvvmLight), implementing the INotifyDataErrorInfo interface. ...
78 views

### Asynchronous TCP network server with a packet system

So I'm writing a game emulator and would like some advice after finishing the networking. It is designed to accept multiple connections, and process messages from all of them. Here is just a brief ...
189 views

So I have a method that, after validation, generates a random password based on the length and characters provided. The UI uses check boxes to select using between lowercase and/or uppercase letters, ...