As of May 31, 2023, we have updated our Code of Conduct.

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
8 votes
5 answers
6k views

Removing exact instances of elements in one list from another

Basically, here's the problem statement: Given an IEnumerable<T> source and an IEnumerable<T> exceptions, return ...
Der Kommissar's user avatar
8 votes
6 answers
13k views

Place try/catch in business logic or user interface

I found the following two types of exception-handling in Business Logic Layer. ASP.NET 3.5 Enterprise Application Development uses a similar method like the first one (I read it few years ago). I ...
Win's user avatar
  • 183
8 votes
2 answers
200 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 ...
pacmaninbw's user avatar
  • 22.4k
8 votes
3 answers
1k views

Dataset with optional addition to where statement

I am trying to generate a dataset from a query that has a where statement. If the user passes a value additional things need to be added to the ...
aaronmallen's user avatar
8 votes
2 answers
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 ...
AJD's user avatar
  • 2,346
8 votes
2 answers
142 views

Let's do some “enciph5r47g”

I implemented the enciphering/deciphering algorithm from this code golf task. Enciphering reads string from left to right, replacing each character by a number N (0-9) to indicate that it is the same ...
Manolis's user avatar
  • 343
8 votes
3 answers
210 views

RPSLS refactored to Object Oriented

I wrote a couple reviews for this CR post. In my most recent review, I refactored @Malachi 's code to fit OO design. I'm looking for any advice/hints/criticisms on it. A review is welcome for both ...
BenVlodgi's user avatar
  • 4,278
8 votes
4 answers
290 views

Maximize profit on a trade route

Fixed trade route with goods and prices and fixed cargo capacity. How can I optimize profit? No cost to trade or transport - just fixed capacity, route, and prices. All products use the same ...
paparazzo's user avatar
  • 5,946
8 votes
2 answers
5k views

Color-coded console output

I wrote this Console.Write function to use in my applications where I need to easily color-code output. Example syntax would be: ...
BenVlodgi's user avatar
  • 4,278
8 votes
2 answers
934 views

Yield statement in a using block from a clarity point of view

I want an opinion of the community about readability and maintainability of the following code. This is quite a rare case when yield statement included in a using construction. I know that this code ...
Appolina's user avatar
8 votes
3 answers
739 views

MIST - auto-implemented, attribute-driven .NET notification mechanism

I have a component that I've used myself for quite some time, the short story is that it automagically implements a property change notification mechanism (very useful for implementing ...
Mik3c's user avatar
  • 101
8 votes
3 answers
3k views

Elevator Interview Problem OOP - Revised

Elevator program code challenge, revised: Can someone please critique my Elevator problem - I wanted to use OOP principles and coding standards. Also, does logic make sense? ...
BobSwanson's user avatar
8 votes
3 answers
117 views

Representing and handling Data Sizes

In a very specific application I have, I needed the ability to easily convert between different data sizes. I.e. when I give an input of 1,048,576KiB, I needed it to say 1GiB, etc. So, I built a <...
Der Kommissar's user avatar
8 votes
2 answers
2k views

Simplification of byte array comparison algorithm

I have an algorithm that evaluates in input byte[] with a source byte[]. Several conditions can be encountered: Match found No ...
IAbstract's user avatar
  • 616
8 votes
2 answers
558 views

WeakCollection<T> class

Occasionally I have need for a collection of objects in which each object is referenced "weakly" (meaning the GC is allowed to collect it even when the object is in the collection). Traditionally, I ...
Walt D's user avatar
  • 181
8 votes
2 answers
5k views

Automatic translation of forms

I want my application to support multiple UI-languages (aka i18n). To do so, I have built the static class below, to automatically translate the form and all its contents to the desired language. It ...
liorda's user avatar
  • 183
8 votes
2 answers
942 views

Drag and drop single files on different targets for different purposes

I have three text fields (DevExpress ButtonEdits set to read only) on a Windows Forms app. They look like this: They're used by dragging and dropping a single ...
kdbanman's user avatar
  • 181
8 votes
1 answer
502 views

Winforms Mathematical Operator Label

I wrote a custom class which (atm) displays the +, -, =, x, and ÷ operators inside a circle. Apart from the issue of some symbols not appearing in the exact center (everything except + looks a bit off)...
Shadow's user avatar
  • 643
8 votes
1 answer
8k views

.Net BouncyCastle - CSR and Private Key Generation

The purpose of this code is to generate the CSR and the Private Key. The scenario is that we have some clients for whom we run websites and for the SSL component we want to have a page on our site ...
Robin Rieger's user avatar
8 votes
1 answer
3k views

Fluent Nhibernate

I'm very new to NHibernate and DB. I have three tables which are connected with many to many relationship. Here are the tables creation Script: ...
Oleg Dobra's user avatar
8 votes
2 answers
8k views

SocketAsyncEventArgs send and receive

I been working on getting the SocketAsyncEventArgs to work the way I want it to work. Now I was wondering: is this going to work how it should work? ...
mmm's user avatar
  • 81
8 votes
1 answer
31k views

Creating a TreeNode hierarchy in C#

The following function accepts a list of Topic entities, retrieved from a database using LINQ-to-Entities. Each Topic has an Id, ...
James's user avatar
  • 450
8 votes
1 answer
6k views

Implementation of the FNV-1a hash algorithm for 32- and 64-bit

Are there any improvements to these two classes which implement FNV-1a for hashing? Particularly, I'm looking for any reuse opportunities (possibly via a common abstract superclass derived from ...
Jesse C. Slicer's user avatar
8 votes
2 answers
5k views

A blocking buffer manager to provide segments of a byte array

Since asynchronous operations (like Socket's Begin*-End* pairs and ...
Şafak Gür's user avatar
8 votes
2 answers
2k views

Attribute driven behaviour in C# methods

We want to create a TransactionScope factory class that we can use as a central point for instantiating TransactionScopes with ...
Eoin Campbell's user avatar
8 votes
1 answer
632 views

Fun with CallerLineNumberAttribute: clever hack or terrible idea?

One fun feature that was added (fairly) recently in .NET is the [CallerLineNumber] attribute, which, in conjunction with ...
Dan Bryant's user avatar
8 votes
1 answer
2k views

.Net TCP Server

I saw this question "Is this implementation of an Asynchronous TCP/UDP Server correct" and it is very similar to what I want to do but it goes about it in a different way so I am wondering if anyone ...
kmp's user avatar
  • 163
8 votes
1 answer
458 views

Using Delegates and BeginInvoke with .NET 2.0 WebServices

I'm attempting to implement a simple long-polling/comet/reverse AJAX solution, and came across the concept of delegates, specifically with the BeginInvoke and ...
Ryan Kinal's user avatar
8 votes
2 answers
195 views

Library for the Summary API (used to get summaries of webpages)

I was wondering if I could get some pointers on how I can improve my library, whether it be design pattern/naming convention/or any ideas on a better implementation. GitHub As it stands, I am using ...
ghostiek's user avatar
8 votes
1 answer
484 views

Analysing Poker combinations

I made a Poker game a while ago and looking at it now, I'm not really happy with the code structure and I decided to revamp some of the core functionalities there, starting with the different Poker ...
Denis's user avatar
  • 8,438
8 votes
0 answers
322 views

.NET DLL Injector in C++

I built a DLL Injector with User-Interface. The program lists all processes, the user chooses one of them and a DLL, and inject it. It's my first project in C++, and I know it's not exactly C++ ...
Gil Mans's user avatar
7 votes
5 answers
32k views

Checking if a text contains N consecutive repeating characters

I want to check a text for consecutive repeating characters. For example, with a minimum of 3 consecutive chars, this should match: Okeee OOOkee Alsoook This should not match: No not okee, oh no ...
LDW's user avatar
  • 409
7 votes
3 answers
616 views

A program that uses three methods to reverse and print an array

I have this code that uses three methods to do certain tasks. One creates an array, another reverses it and the other one prints it out(it was required to use three methods). A person recommended me ...
anon's user avatar
  • 73
7 votes
3 answers
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 ...
Martin C's user avatar
  • 130
7 votes
5 answers
1k 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 ...
Jakob Busk Sørensen's user avatar
7 votes
2 answers
749 views

Proper handling of exceptions in MVP

In my DAL currently I'm handling exceptions as follows. Is it in an acceptable level? Note : I'm using MVP in this Winforms application. ...
CAD's user avatar
  • 1,753
7 votes
5 answers
2k views

A simple unrolled linked list implementation

I tried to implement an unrolled linked list in C#. I only needed to add things and clear the whole list so I didn't implement IList<T> (I tried but it was ...
Şafak Gür's user avatar
7 votes
6 answers
12k views

Code to initialize a .NET object from a CSV file

I am initializing the following object from a CSV file: ...
EJoshuaS - Stand with Ukraine's user avatar
7 votes
5 answers
4k views

Optimizing multiple if-else from static class with LINQ

I have a static class: ...
Simsons's user avatar
  • 723
7 votes
3 answers
10k views

Thread overkill with async/await

Consider the following code. ...
kasperhj's user avatar
  • 171
7 votes
3 answers
3k 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 ...
Delfino's user avatar
  • 509
7 votes
2 answers
19k views

Task timer async

I had been still using BackGroundWorker and decided to learn async Task. My test project is a simple timer that can be canceled. The target project is to read instruments with a delay for sampling. ...
paparazzo's user avatar
  • 5,946
7 votes
2 answers
648 views

Color structure with single field for multiple properties

This struct is used a lot throughout my programme. This struct is responsible for only things regarding colour, not anything else. I'm largely concerned of the ...
Der Kommissar's user avatar
7 votes
2 answers
1k views

Playing card game method

Is there a better, more elegant solution to the following method? ...
Tommaso Belluzzo's user avatar
7 votes
3 answers
415 views

XNA KeyboardStateManager

This class allows for easy management of the KeyboardState of an XNA game. It provides a simple, easy-to-use API for interacting with the Keyboard and getting key-...
Der Kommissar's user avatar
7 votes
2 answers
409 views

Which option is better for readability when dealing with blank strings?

I'm working off a specification that says a bunch of fields within a record (one record being one line) must be blank. For example, it says that chars 6-14 must be blank. I am building a class ...
ldam's user avatar
  • 173
7 votes
4 answers
3k views

Function for formatting a timespan with optional trailing zero

I'm looking to achieve a time format that looks like this: 2d 4h remaining; or 1h 36m remaining; or 35s remaining, etc. So that it only displays the two largest values of time (this is how Clash of ...
Essential's user avatar
  • 255
7 votes
3 answers
371 views

Implementing Dynamic Network Message Handling (Part II)

This is an iterative review request of this other question I posted. As a follow up to that previous question, I changed the pattern completely and I went to an events-based approach, which might be ...
Der Kommissar's user avatar
7 votes
2 answers
597 views

Palindrome program needs improvement

Here a string is taken as input and the program suppose to check whether the string is palindrome or not. Is there any way the code can be improved? Is it okay to use foreach to break the string into ...
AKdeBerg's user avatar
  • 195
7 votes
3 answers
854 views

Method for returning valid URLs from a sitemap URL

I need a method which fetches all of the text from a URL (generally a sitemap URL), and returns an IEnumerable of all valid URLs contained in the text returned from ...
b4040325's user avatar

1 2 3
4
5
25