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.

Filter by
Sorted by
Tagged with
1
vote
0answers
32 views

calculate time in data processing into XML and CSV [closed]

I made a program (C#, .NET) that calculates time for XML and CSV export and please I have a question for improving my knowledge in programming. Do you think that I can improve the structure of the ...
5
votes
0answers
121 views

Display Child View and Subscribe to its event on ReactiveUI

I am very confuse what is better approach to display child view and subscribe to its event on ReactiveUI WPF, so far I have 2 implementation that somehow works for my case: Implementation 1: ...
6
votes
3answers
162 views

C# Event Manager without allocations

I'm using my own Action-based Event Manager for a while and looking for ways to improve it. Mainly it's used in game development, where excessive garbage generation can lead to severe consequences. ...
4
votes
1answer
167 views

Architecture Logging

I have two database tables UsersDownload, Non-UsersDownload. There is also two model object and two service that take in the object and insert the data into the correct table. Is this the best ...
1
vote
0answers
14 views

xamarin SegmentedControl

I wanted to know is this the best way to handle a SegmentedControl using the e.NewValue? Base on the selected segment I hide and select different data? XAML ...
2
votes
2answers
140 views

Is it good to use the builder design pattern for HttpWebRequest?

I've a C# WinForms application that relies heavily on sending HttpWebRequests. I've build an HttpWebRequestBuilder, and ...
2
votes
1answer
95 views

Vectorization, 7-bit encoding

I was curious how vectorization works and how to write suck code. To start simple I choose 7-bit encoding as my test suspect. I'm not expecting improved throughput in any way. My implementation works ...
1
vote
0answers
61 views

Reactive Extensions wrapper around Confluent.Kafka for .NET

Just an Rx wrapper around Kafka to represent topic consumption as IObservable<T>: ...
1
vote
0answers
35 views

Maximal Bipartite Matching

I have been working on creating a code solution for the Hungarian Algorithm, and from the testing, the slowest and buggiest part has been the bipartite matching. The most recent rendition is based on ...
0
votes
1answer
64 views

Unit testing an unspecific order of method calls [closed]

I cannot figure out how I am supposed to unit test the implementation of GetFilteredEntites(IEnumerable<MyEntity> myEntities). ...
3
votes
0answers
118 views

UPDATED: Ambient time context to help unit testing

The following test demonstrates the functionality of Time class which is supposed to be used instead of DateTime.Now. You could ...
0
votes
1answer
52 views

Schedule talks in tracks [closed]

Consider my simple business requirement as follows: There is a list of talks and they need to be scheduled in tracks. Each track has a morning session starting at 9am and an afternoon session ...
1
vote
0answers
39 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 ...
3
votes
0answers
160 views

C# Rest Client Benchmarking

I build a C# Rest Client library / framework. I noticed that it seemed to be significantly faster than RestSharp for GET at least. So, I decided to put together some benchmarks comparing it to other ...
1
vote
0answers
84 views

HTTP Client - Best practices

I've made a HTTP client and would like some tips to improve my code, it's supposed to be built for xamarin forms but should work with any implementation. My goal of this project was to learn more ...
1
vote
3answers
142 views

c# IndexOf string search

I have this code working but its using IndexOf I am not sure if that is the best or only option for search for a string value. What I have is a list that will need to remove a world from the child ...
1
vote
1answer
144 views

Connect 4 class in C#

I wrote the following class for a connect four game in C# ...
1
vote
0answers
82 views

get better performance [closed]

I have this code that works, but I'm sure that it can be done better, any suggestions? ...
4
votes
1answer
49 views

Multi-threading with TPL - Access Internal Class Properties

I am using the TPL library to parallelize a 2D grid operation. I have extracted a simple example from my actual code to illustrate what I am doing. I am getting the desired results I want and my ...
2
votes
1answer
50 views

Validate implementation of ECIES

I've created a basic implementation of ECIES (Elliptic Curve Integrated Encryption Scheme) based on http://www.secg.org/sec1-v2.pdf section 5.1. ...
1
vote
0answers
62 views

Abstract vacation time tracker with states [closed]

I am writing a program for vacation in a company and the time that is allowed to be in a specific holiday I used an Abstract class with an abstract method: ...
0
votes
1answer
29 views

c# Ftp.UploadFile

I am trying to improve working code seeing if there was any potential issues or performance problems. This code will connect to an ftp server and upload a file. ...
1
vote
2answers
93 views

Async Check for Domain Fullname With WPF and Caliburn.Micro

I have a small WPF program built using Caliburn.Micro which checks Active Directory for a user with the current username of the logged-on user. I have a Bootstrapper...
3
votes
2answers
166 views

Adding a cancellation token to TcpListener.AcceptTcpClientAsync()

There is no facility in TcpListener (or for that matter Socket) to close a listening socket that is waiting for a connection without throwing an exception. After running up a test bench with 8 ...
0
votes
0answers
43 views

Array of varied dimensions

I wrote a UltraCube class whose purpose is to provide an array of custom number of dimensions. This was created because I needed to make number of dimensions for ...
4
votes
1answer
134 views

Method that filters a list parameters based on different fields

I have this code which is a callback for Filter in WPF ICollectionView. When I run code analysis, the cyclometic complexity is reported to be 11. I consider this ...
0
votes
0answers
50 views

Downloading large amount of data and storing on Android & iOS

So I have this API that downloads from our web service, but the we service sends it as a ZIP file instead of a json stream or something else. Now the files can get quite large butt they are not ...
1
vote
1answer
44 views

C++ Wrapper and Correctly Disposing Unmanaged Resources using ArrayHandle

I have the following class ...
1
vote
1answer
98 views

Increase Perfomance of Nested Object Instantiation C#

I'm filling a list of items from the database, which is taking extremly long time to run (Approx 60 seconds) Here is the code with the relevant breakdown 97% of the performance issues come in the ...
3
votes
1answer
234 views

C# Windows Forms App: Adding An Element To The BindingSource And Save These Changes To The DB [closed]

I have build a C# Windows Forms app that used Entity Framework(DB first model). For the data I am using a .mdf database file. The data view of dbo.students: GUI: The Form1 class: ...
-1
votes
1answer
55 views

Extract a substring from a string without using the library function.[C# Console Application] [closed]

My Solution for Question 13 on https://www.w3resource.com/csharp-exercises/string/index.php ...
2
votes
2answers
123 views

Right way to handle, log and display exceptions

I repost my question here because it has been closed on stack overflow This question could sound stupid but I am new to the logging, displaying and handling exceptions. Because before I was just ...
2
votes
1answer
46 views

Handling external API calls status code in my application

I have a Web API application in .NET Core 3.1. In a controller I have a GET action that must return a JSON object with a name and a description. In order to retrieve the correct description I need to ...
7
votes
4answers
253 views

Reducing code duplication for my C# math class

I have a library with a lot of duplicate code to accommodate different collection types, and its starting to get a bit tedious, is there a better way to do this to reduce the amount of duplication ...
2
votes
1answer
64 views

Inserting large amounts data into Excel spreadsheet

I have a VSTO Excel Add-In which is used to retrieve data from another application and insert it into an Excel worksheet. Due to the potential for lots of pieces of data to be inserted into a ...
3
votes
0answers
140 views

bowling game score calculator

I'm new to the Developers world and I have project that I've been working on. It's to calculate the Bowling Game Score (similar to the Hdcp Score done by this tool: https://bowlinggenius.com/ ) I'm ...
1
vote
0answers
54 views

Zen and the Sieve of Eratosthenes - Part 1: A Basic Windowed Sieve

The Sieve of Eratosthenes is one of the oldest known algorithms and yet it is still the best method for sieving prime numbers in bulk in many situations. It is brutally simple, but to make it brutally ...
3
votes
0answers
64 views

Correct and safe way of performing token exchange?

I am dipping my fingers in external apis that a user would login and retrieve a code to exchange for a token. In my case, it is for the SpotifyAPI. All the web app does it return the users top ...
1
vote
1answer
40 views

Using Reactive Extensions in an Asynchronious Way

I am new to Reactive Extensions, I have the requirement to consume PairCollection<IPointCloud> which are fed into a service which performs a very expensive ...
1
vote
2answers
80 views

Autofac support for connection strings

I would like Autofac to instantiate components based on connection strings in the form of the URI: ...
3
votes
1answer
164 views

Strongly typed unit system in C#

I am working on a Units library for a personal project that is a physics-heavy C#/Unity3D game, and I am looking to improve it in a few areas: 1) Is there a way to reduce the code duplication? 2) Is ...
1
vote
3answers
176 views

Rock/Paper/Scissors using C#

I created a Rock/Paper/Scissors game in C# that asks the player the number of rounds he wants to play, and then calculates the points and determines the winner. Is there a way I can fix my code? Is it ...
1
vote
2answers
92 views

C# Ping - Checking availability of hosts

Simple Console Application for checking if one of the hosts is available. The implementation should be for around 5 hosts to check with different response times and the method should return fast when ...
3
votes
1answer
54 views

Basic Unit Test of Application Service, setup and cleanup methods

I'm not experienced with testing, therefore I'd like you to look at my code proposal of unit test. My solution has following projects Tests\Application.Tests Application Domain Infrastructure Web ...
1
vote
1answer
105 views

String Split a phrase into sentences

Hello this is a Console App(.Net Core) in Visual Studio 2019 and i am trying to split a string into sentences and then add them into a dictionary with Key the first word of the sentence and Value the ...
5
votes
2answers
79 views

NewSequentialId - pure net core 2.2 implementation of sql server function

i'm currently trying to rewrite sql server newSequentialId() function in pure c# that is performing as fast as possible and eats minimum memory. Question is can I it be done better - current ...
0
votes
1answer
41 views

c# QuadTree yielding properly [closed]

I have implemented a QuadTree of my own, and I'm afraid I didn't use yield properly when I query my tree, my fear is that I create O(HN) iterators. Could you direct me how to better improve the ...
-3
votes
1answer
57 views

Find the starting index of all occurrences of a pattern within a string

...
4
votes
1answer
114 views

C# program which measures the distance between the average and maximum/minimum temperature

The program below takes inputs for the temperature in various cities in a span of multiple days. It then outputs the ones where the minimal temperature is closer to the average than the maximal ...
1
vote
1answer
56 views

Image type convertion

So I have a piece a code that, altough it does what is expected, it doesn't seam very performant to me. I just wanted to know if there's a better way to do this or if my code is alright as it is. The ...