Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [.net]

.NET is a software framework supporting a multi-language paradigm and supporting language interoperability. .NET applications are executed in a virtual machine (CLR) which provides a few important services: security, memory management and exception handling.

Filter by
Sorted by
Tagged with
3
votes
2answers
78 views

Validate if either or both of two fields has been provided, as a ValidationAttribute

I have a binding model where at least one of two fields must be specified. I can't just set them both as [Required]. Here is what I came up with: ...
4
votes
0answers
25 views

WPF Custom Control with a Single ObservableCollection DependencyProperty

I'm learning how to write WPF custom controls. My example, NameLister, exposes a single DependencyProperty, Names, of type ...
3
votes
1answer
56 views

Formatting a type's name

I'm writing a code generation library, I've exposed a couple of methods and of course in order to define a member you need to specify it's type, the easiest way is to use ...
1
vote
0answers
65 views

Running some code every day at certain times

I am currently developing a windows service in C# which is supposed to run a data import every day at configurable times. For this purpose I have created a class "ExecutionTime" which contains the ...
5
votes
1answer
125 views

Encrypting credit card data

I need an encryption algorithm that would be secure enough to store credit card data. So it should be reasonably secure. Here's what I've come up with. I'd appreciate any constructive criticism. <...
0
votes
0answers
36 views

Stream wrapper for base 64 string

We have a scenario where we are receiving file as base64 string. This is not ideal and should be a binary stream. Because with file size memory utilization grows very rapidly as base64 representation ...
1
vote
1answer
34 views

Small service for hashing and validating passwords, using PBKDF2

As part of a larger authentication/authorization system, I've developed a small .NET Core 3.0 service for hashing passwords using PBKDF2 (with a salt) and validating passwords against a stored hash/...
2
votes
0answers
29 views

Seekable HTTP response stream wrapper

I created this wrapper to use together with HttpClient streams and ZipArchive. ZipArchive ...
19
votes
4answers
2k views

Matrix class in C#

I've been learning C# during my free time in the past months; before that, I was mostly writing Java, so the transition hasn't been too hard, but I've never had my code reviewed or read by someone ...
3
votes
2answers
107 views

Parcel size classifier [closed]

I submitted a technical assignment for a job interview process and I am stressing out wondering if my submission was any good. I would like to learn and be a better developer, so please give me ...
-1
votes
1answer
46 views

Reduce CPU utilization in constant pinging to API and saving data in to database service [closed]

I have this hosted service which grabs the data from API every second and process the data and save it into the database. I have similar 3 more hosted services which run at the same time. Because of ...
2
votes
1answer
72 views

Hosted service which perform CRUD operations in high update environment

I have this hosted services which garbs the data from the API and save it in the database. But before saving it checks if the data already exists in the DB if not it creates the new row and if it ...
4
votes
2answers
118 views

DropDown tree with search

I fetch a bunch of categories for a DropDown tree, and have to implement search in this dropdown. If there is a match in one of the elements, it should also get all ...
2
votes
1answer
44 views

Posting images from request to Azure blob

I have base Controller for Attachments, here is code of it In this controller, I pass data from the request and return URL of the posted object. ...
1
vote
0answers
61 views

What pattern can I use to write CRUD functionality? [closed]

I am writing a console application. CRUD functionality.I would like to try to apply the pattern. Is it possible to apply a "state" pattern? In the AddCustomer () ...
3
votes
1answer
114 views

Capsulation solution for byte arrays

In a part of the project, I had to implement a solution for encapsulation of byte arrays. We do use ssh and secure ports for socket connection but I was in need of an extra layer of protection against ...
8
votes
2answers
1k views

ROT13 encoder/decoder

This is a simple utility, intended to sit on the desktop for when needed, that does the simple ROT13 encoding and decoding. I am used to coding in VBA, and I am interested in more .Net idiomatic ...
3
votes
1answer
72 views

Compare performance of Concurrent Dictionary with Dictionary+Locks

I wanted to measure the performance of Concurrent Dictionary vs Dictionary+Locks in a multithreaded environment. So I created my own SyncDict class of type...
5
votes
2answers
266 views

Safe Dispose of Timer

I am currently refactoring a larger solution where the compiler gave multiple warnings about disposing the used System.Timers.Timer instances. The timers are ...
3
votes
1answer
60 views

Calculating all flight connections

I am working on an API to return all the possible flight route between point A and B. I have a set of data which includes the flight number, airline, departure airport, destination airport, departure ...
1
vote
1answer
164 views

Do these BLL-DAL comply with the Dependency-Inversion Principle and is this valid Dependency Injection?

I am working on a very simplified proof of concept (POC). Separation of concerns should be achieved in this project, so that in the future we have flexibility in respect of what data source we use (...
7
votes
3answers
533 views

Compiling all Exception messages into a string

Below is a recursive function I've written that's responsible for compiling a string consisting of a Exception's message, and also each of that ...
1
vote
2answers
107 views

Get value from a dictionary contained in a dictionary

I have an API that returns a dictionary of dictionaries. I currently have this code to access the value of the dictionary, but it looks like a code smell. Is there a better way to structure this? <...
3
votes
0answers
48 views

msmq bulk send in c# [closed]

Please review the code below and provide constructive feedback to improve. Multiple threads call the SendMessageToMSMQ method to send messages to a msmq queue. ...
2
votes
1answer
73 views

Should I re-throw exceptions within a method, or is there a better way to handle it? [closed]

When handling errors in C#, is it acceptable/appropriate to re-throw exceptions that are caught in a try/catch? My scenario is that I am making an HTTP request and ...
1
vote
2answers
104 views

Object-oriented implementation on Expense Tracking App [closed]

I am creating a Expense Tracking Application in C# and right now I am trying to build its building blocks in a console app. I Would like to know your feedback if it is in a Object Oriented Design/...
5
votes
1answer
71 views

Rate limiting variable-duration operations over a time interval

I want a rate-limiter that permits, at most, N operations over T seconds. I found a sample implementation here but it makes an assumption that operations complete in a predictable, consistent amount ...
1
vote
0answers
36 views

string.To2DCharArray extension method implementation

I would like to ask a code review for the class below. I am asking this because VS showed a quite low Maintainability Index of 54 and I am wondering if it is good code. I know I could have extracted ...
0
votes
1answer
44 views

proper structure of classes using interface classes [closed]

Given the following two interfaces what would the proper way to set up the two actual classes? ...
-4
votes
1answer
56 views

Generic Custom STACK Class for Hanoi Problem in C# [closed]

I have created a custom class (Generic) in C# for the Hanoi problem. and I am not sure I did the correct thing. ...
6
votes
5answers
220 views

Take N elements from List of Lists

I've come with a solution super tricky for a simple requirement. I think I could solve the problem using LinQ, but I'm not seeing it so clearly at all. What's sure, I'm not comfortable with my code. ...
1
vote
0answers
62 views

Way to hide logic behind class for better readability of method and refactor class to follow SRP [closed]

I have an algorithm to create a version for an entity and then I save that version against below 2 entity: 1) Variant 2) Category ...
-5
votes
1answer
367 views

Would you consider this little project to be worth showing to potential employers? [closed]

I am self thought c# kiddy and wonder if little projects like one here, are worth showing to potential employers when looking for junior developer position. This code has some issues that i do not ...
3
votes
0answers
97 views

Java code to convert BigDecimal to/from .NET decimal

Background In many languages we have built-in data types for representing decimal floating point numbers. In .NET that's decimal, and in Java we have ...
5
votes
2answers
169 views

Finding min value of an array using SIMD

I have the following code to find the minimum sbyte value in an array. It is using System.Runtime.Intrinsics to perform a SIMD ...
1
vote
1answer
75 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-...
3
votes
1answer
90 views

Assigning values to array elements based on a lookup table

I am writing a C# program wherein I need to populate an array based on a lookup table and set of string arrays with metadata. My lookup table looks like this (Table with key: transmitter, value: Array ...
1
vote
1answer
57 views

Encrypts using AES with random initialization vector meant for data with limited visibility and then long rest

I've done some research, reviewed countless SO questions that appeared similar, leading me to endless rabbit holes. My solution is working, but I don't like it. I want to create a random IV for AES ...
4
votes
2answers
77 views

/proc/net/tcp results filter and converter

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
35 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 ...
1
vote
1answer
148 views

IEnumerable<T> async serialization

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

Concise way of “updating” element in nested collections

Imagine simple game: ...
1
vote
0answers
81 views

An arithmetic operation app in C#

One of my friends was creating an app with following requirements and having been someone with slightly more coding experience, I wanted to help: Create a calculator that does one arithmetic ...
5
votes
1answer
142 views

In-Memory database supporting transactions

I referred to the post here but it does not address the question that I have with regards to my implementation. I have a C# implementation of an in-memory database that I came up with during a recent ...
4
votes
3answers
203 views

Poker Game: Refactor method to evaluate poker hands

Preface: I've perused the other related questions before creating this one but I believe that those solutions weren't applicable to my situation. I'll concede that its possible that I may not have ...
2
votes
2answers
124 views

Generic Singly-Linked List implementation

I'm looking for some feedback regarding my implementation of a generic singly-linked list in C#. I'm also looking for some tips on how to implement other techniques such as using ...
4
votes
1answer
360 views

SemaphoreSlim extension method for safely handling cancellation and disposal

I have often found myself using a try {semaphore.Wait()} finally {semaphore.Release()} pattern when using a semaphore, so decided I wanted to try and write an ...
3
votes
2answers
190 views

Implement Immutable Collection in C#

I would like to define some constant sequences (of bytes, specifically) in my C# library/API. Both length and content should not vary, preferably by any means (barring reflection). To this end, a <...
8
votes
2answers
139 views

Non-Entity framework database interaction model

A C# WPF user interface has been developed for the Book Inventory MySQL database previously shown in this question. Since the database had already been developed this was a database first ...
7
votes
5answers
636 views

Find the next monthly expiration date

I have an agreement with a customer. When the agreement ends, the customer needs to pay. The amount which the customer needs to pay increases for each month that has passed since the agreement was ...