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
1
vote
0answers
37 views

DataGridView Undo/Redo Manager in C#

While answering this code review question, I proposed a solution with List<DataTable>. I am trying to encapsulate this data structure into a "...
1
vote
2answers
60 views

.Net core string symmetric encryption

I need to store sensitive strings in DB, so decided to encrypt it in a DB and decrypt it at the application layer. And noticed that it is not so easy to find ready to use an example. Please check my ...
0
votes
1answer
36 views

Downloading multiple log files

This code succeeds in downloading log text files from multiple URLs. Can this be made more efficient? ...
2
votes
0answers
36 views

Repository pattern with NHibernate and Autofac

here I leave my code for a repository pattern with NHibernate and Autofac. I would like to receive some feedback about it. Especially about the session handling with NHibernate. By now I don't like ...
1
vote
2answers
71 views

What would be the idiomatic F# way to write optional parameters?

In the context of a library to generate random credit card, it would be nice to let the user the possibility to set some optional options on some cards. Lets take Visa. Two lengths are available: 13 ...
0
votes
1answer
29 views

Remove and add connection string

I want to remove a connection string that may already have been set in a different config file and then set it again. Say my application has a Web.config file and a Web.Debug.config file then I can ...
0
votes
0answers
45 views

.net core console app read from external API and write into a database

I have a .net core console app that gets some data from an external API and inserts it into a SQL database table. It is working as expected but I wonder if you guys have any suggestions to make it ...
1
vote
1answer
56 views

Byte array comparison - efficiency

I have a TCP Listener with NetworkStream that reads 530 bytes from the Client once a second. Within the TCP Listener ...
2
votes
1answer
71 views

Is repository pattern violated while using IQueryable outside of it?

I am writting an API backend application using .NET Core and Visual Studio. Here is the solution structure: [ProjectName] - Solution ...
0
votes
0answers
68 views

Is there a way to optimize this graphics/bitmap drawing code in C#?

I am not doing anything fancy so not sure if there are any tricks to make it faster. It's a progress bar where I draw some numeric text on top. I only draw 1 pixel height image and then resize it. But ...
1
vote
1answer
114 views

Eliminating repetitions of subsequent items in a list

I would like to convert a list A A = {1, 12, 3, 3, 3, 8, 5, 5 } into list B ...
0
votes
1answer
83 views

Big Sorting - Performant Sorting

Consider an array of numeric strings where each string is a positive whole number. Sort the array's string elements in ascending order of their numeric values, and return the sorted array. Return: ...
0
votes
1answer
51 views

How to make this code follow Solid Principle C# [closed]

Currently I have this code: ...
4
votes
1answer
63 views

Minimum number of copies of an application a company needs to purchase

Some applications from vendors are allowed to be installed on multiple computers per user with specific restrictions. In our scenario, each copy of the application (ID 374) allows the user to install ...
2
votes
1answer
66 views

Giving an alternative Async method to a service [closed]

I have an interface, implemented by a service, that I inject here and there in my codebase. I would like to give the opportunity to use either the normal method or its async equivalent. ...
2
votes
0answers
75 views

Simple Sqlite-driven WinForms app in C# 7.0 - database interaction code

Description This is a simple "demo" app designed to help gain familiarity with interacting with an Sqlite database from C#, particularly storing images as blobs. The database has a single ...
2
votes
1answer
108 views

Reviewing Basic API

I'm learning ASP.NET and I've created a few simple APIs, so I can consider myself maybe an intermediate beginner. I've decided to create a tutorial serving two purposes: to solidify what I've learned ...
5
votes
2answers
211 views

C# Logical and Math expression parser

I needed a simple parser that could do both logical and math operations expressed in a string, as well as being able to use variables stored in json. None of what I found online seemed to do all of ...
3
votes
0answers
111 views

Console Password Manager in C# in 370 lines

This is a console password manager in C# script. It has 370 lines of code, from shebang to the last }. Are there any ways to make it even smaller without inlining ...
1
vote
0answers
24 views

Preventing the user from entering the same categories [closed]

I'm new to MVC and EF so this may be a really simple question, but what is the best way to prevent the user from trying to enter duplicate records? I have a table called Category with two columns Id ...
2
votes
1answer
41 views

Determine dependency injection type at runtime from config

I have a .NET application with a .config file that has content like this: ...
2
votes
3answers
131 views

C# Update account based on user order data. Nested if-else optimization with almost similar values

The method works, but I would like to know if there is any way to make it more readable, optimized? I have user data (i want to import/update it). Accounts is finded by user data. ======== User order ...
4
votes
1answer
57 views

C# KeyNotFoundException with more information

Preliminary rant: System.Collections.Generic.KeyNotFoundException : The given key was not present in the dictionary. Oh. My. So I finally got fed up with how ...
3
votes
1answer
65 views

Different versions of the Operate method

I have code that basically is the same, but depending on the number of arguments you provide (up to 5), it will operate with them in a very repetitive way. I have the feeling that this can be ...
3
votes
2answers
213 views

Build byte array from multiple different types of data for sending over a network

The following codes purpose is to generate an array of bytes that represents some user defined data. This array of bytes will later be used for sending over a network. ...
-1
votes
2answers
72 views

How can I refactor a function to be inline? [closed]

I'm refactoring functions trying to do more of a in-line aproach. ...
3
votes
2answers
77 views

Exporting objects in various formats while reporting progress

Description A WinForms application has a function to export objects of the following type, in various formats: ...
2
votes
0answers
23 views

Applying OOP to refactor my Windows Forms APP [closed]

Could you please give me some direction about how I could refactor my code? As I add functionalities to my Budget App the class is getting bigger and I'm sure I could start looking at separating ...
1
vote
0answers
89 views

Code refactor - eliminate generic interface and object methods

I'm building a method that tries to detect whether given information about an object's property to retrieve, a constraint operator and some data to compare it against, whether the result is true or ...
7
votes
3answers
2k views

C# Am I using proper SOLID principles?

I am currently practising using the SOLID principles in C#/.NET I have made a little example, but i am not sure if i have followed it correct. Its a simple example where i have an API controller that ...
3
votes
1answer
400 views

Undirected graph data structure in C#

Description A class representing an undirected graph. At the moment, it supports integer values as vertices. An example of the type of graph represented is shown in the following diagram: It is ...
3
votes
2answers
127 views

Refactor multiple if-else conditions when condition is a minor change

I'm new programmer and I'm working on Xamarin MVVM app and I have a pin view like So, basically I have numbers from 0-9 if you pick one number its visible then if ...
7
votes
1answer
326 views

Is Lock necessary to make operation thread safe for this scenario

I have the following method that is responsible for retrieving an Item from the database. There will be multiple threads instantiating this class, so I want to make ...
12
votes
2answers
505 views

C# - name separation & last name in upper to Camel

I had an xls file with lots of full names in the following form at work: ...
3
votes
1answer
80 views

Simple Password Generator Feedback

This is my first major project in F#, looking for any critique on how I can make it more standard or more concise. Some things I feel like I could have done better are the command flag parsing and the ...
-2
votes
2answers
80 views
1
vote
0answers
124 views

C# Neural Network project

I'm writing a NeuralNetwork library, so everyone could use it and I'm wondering if I can optimize it even more. Here is my GitHub repo if you want to check the whole project (I recommend using the <...
1
vote
0answers
48 views

Find assemblies in subfolder of primary assembly

I'm using the following handler to resolve assemblies in a specifically named subfolder of the main assembly's folder. I am looking for improvements in: clarity correctedness flexibility, as long as ...
1
vote
2answers
109 views

Building a Word document containing two different tables

I am trying to generate a Word document with two different tables inside it. For this purpose I have two similar methods where I am passing word document reference and data object and table to the ...
1
vote
1answer
57 views

Update cache with minimal blocking

As part of the task, it is allowed to use slightly outdated data. It is required that only one thread per key is involved in the critical section, while the remaining threads use data from the cache ...
2
votes
0answers
270 views

C# class to dump the memory of a process in several formats

I made this because I couldn't find any good C# classes/libraries that allow you to dump the contents of a process' memory into a file or a byte array. I haven't tested this on 32 bit systems but it ...
3
votes
1answer
145 views

In Memory Database in Unit tests, isolate the tests

I have stumbled across these unit tests in a code review that are using in memory db: ...
3
votes
1answer
101 views

Writing a c# class that has enum like constraint while behaving like string

Following This post : https://stackoverflow.com/questions/630803/associating-enums-with-strings-in-c-sharp/56482413?noredirect=1#comment107635743_56482413 I wanted to go further as it didn't quite ...
2
votes
0answers
33 views

Email Service - Sending an email with azure blob storage Version 2.0

Now implemented changes suggested in my previous post and now am back again for the internet to tear me and my shitty code down. PatchNotes Extracted templateRetriever class from the email service ...
1
vote
1answer
225 views

Email Service - Sending an email with azure blob storage

Here is some code that sends an email using Mimekit for .net C# to send email via Office365. DI is done using TinyIOC. It downloads an image from blob storage and then sends it with an attachment. ...
3
votes
1answer
35 views

Compare 2 directories for equality

Currently, I'm working on a legacy application written in .NET that does not contain any unit tests. This application, when executed produces a very large directory tree with roughly 20.000 files in ...
-1
votes
1answer
151 views

ASP.Net Core API JsonPatchDocument

Hi I am creating a website for my chiropractor and I am creating the API for data access. I am creating a HttpPatch Method and want to know if this is the right approach so would be grateful if you ...
2
votes
1answer
54 views

Enum conversion to Enumeration class with small Business Logic inside

I had old enum, I converted it to Enumeration class and added one method inside (isValid). I am not sure if it is good approach ...
1
vote
1answer
39 views

String Concatenation and Comparison

I have the below code. I have list of status which contain may contain 4 values. R,UR,DO,NDO based on this list. i need to convert to Y,N values If list contains R the Readstatus="Y" If list ...
1
vote
1answer
73 views

My simple implementation of a DI container

I decided to make my own light DI container. I know about Zenject, etc. I wanted a very light analog. I'm concerned about a few things: 1) is it correct to use struct instead of class for reference ...

1
2 3 4 5
23