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
2answers
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 ...
8
votes
2answers
398 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 ...
8
votes
1answer
16k views

Implementing IList<T>, IList & INotifyCollectionChanged

I posted this question over at Stackoverflow, which was off-topic. I was using ObservableCollection in a number of places in my WPF application for very large ...
8
votes
2answers
4k 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 ...
8
votes
1answer
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: ...
8
votes
2answers
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? ...
8
votes
1answer
29k 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, ...
8
votes
2answers
5k views

Using Roslyn to find interfaces within a solution

The intent of the below code is to find all interfaces within a solution whose fully-qualified names match the given predicate. It seems to work, but as I am new to Roslyn I'm guessing there are ...
8
votes
2answers
5k views

A blocking buffer manager to provide segments of a byte array

Since asynchronous operations (like Socket's Begin*-End* pairs and ...
8
votes
2answers
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 ...
8
votes
1answer
1k views

Creating interactive tours for WPF applications

I am developing a WPF component that can be used to create interactive tours for WPF applications. To further improve the API in terms of usability and intuitiveness, the input of other developers is ...
8
votes
1answer
538 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 ...
8
votes
1answer
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 ...
8
votes
1answer
369 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 ...
8
votes
2answers
180 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 ...
8
votes
1answer
433 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 ...
8
votes
0answers
260 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++ ...
7
votes
5answers
25k 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 ...
7
votes
5answers
4k views

Return Nth Weekday of Month

My goal is to obtain the nth weekday of a given month. Parameters are a date from a given month and the nth weekday I'm trying to obtain. It returns the Nth Weekday of the month if it exist and ...
7
votes
2answers
713 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. ...
7
votes
5answers
653 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 ...
7
votes
5answers
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 ...
7
votes
6answers
9k views

Code to initialize a .NET object from a CSV file

I am initializing the following object from a CSV file: ...
7
votes
5answers
4k views

Optimizing multiple if-else from static class with LINQ

I have a static class: ...
7
votes
3answers
10k views

Thread overkill with async/await

Consider the following code. ...
7
votes
3answers
553 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 ...
7
votes
2answers
15k 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. ...
7
votes
2answers
1k views

Playing card game method

Is there a better, more elegant solution to the following method? ...
7
votes
3answers
391 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-...
7
votes
2answers
542 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 ...
7
votes
2answers
389 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 ...
7
votes
4answers
2k 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 ...
7
votes
6answers
12k 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 ...
7
votes
3answers
350 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 ...
7
votes
2answers
571 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 ...
7
votes
3answers
724 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 ...
7
votes
3answers
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 ...
7
votes
3answers
6k views

Vending Machine

After doing a lot of reading and practicing, I've come up with a simple program that implements multiple OOP techniques, principles and several design patterns such as Observers, Factories and ...
7
votes
4answers
13k views

Count duplicate List<int>

Count duplicate List<int> in List<List<int>>. A duplicate is not order-dependent. { 1, 2, 3 } is a duplicate ...
7
votes
2answers
1k views

Tuning Excel calculation engine which uses MS Excel interop

I am currently building an Excel calculation engine. Its purpose is basically to wrap the calculation logic of an Excel workbook in order to use the logic from a C# library. ...
7
votes
2answers
2k views

Combining List<>.ForEach and List<>.Zip

I have three lists, and I need to operate on the ith element of each list simultaneously. ...
7
votes
1answer
8k views

Removing accents from certain characters

I have a method that I am using to remove accents from certain characters. The problem is the massive slew of characters I am expected to work with. I have to, basically, remove accents from all Latin ...
7
votes
1answer
305 views

Somewhat esoteric if statement in a paginated feed

I am working on the home page of a website that will have a paginated feed (much like a blog's home page). One of the requirements is that when a user navigates to a non-existent page, he or she will ...
7
votes
5answers
5k views

A generic singleton

What do you think about this for a generic singleton? ...
7
votes
1answer
5k views

Serializing objects to delimited files

For a new project I'm going to need to be able to serialize random types to TSV or CSV files, so I write a class which can be used to serialize any object to a TSV, CSV or any other _SV file you can ...
7
votes
3answers
23k views

Correct way to delete elements from a ConcurrentDictionary with a predicate

I have written a caching wrapper class for ConcurrentDictionary. Basically it has a timer that checks if items are expired and removes them. Since ConcurrentDictionary does not have RemoveAll method ...
7
votes
2answers
33k views

Is there a better way to search directories for a file or files?

Edit: The purpose of this method is to search a specific directory for a given file type, ex. (*.txt, *.pdb, *.exe") then move the file(s) to a given destination directory and delete the original ...
7
votes
3answers
515 views

Go through every pixel of an image and then dispose of it

I'm a little confused as to whether implementing the Dispose method serves a purpose in this code. It never gets referenced by any other class in my project, so ...
7
votes
4answers
7k views

Get nested type name without namespace

Suppose I have a nested class structure like this: ...
7
votes
2answers
6k views

Recursive database actions

I am been using a code pattern for recursive database actions in my applications. I create two class objects of a database table, singular one (e.g Agent) for holding single record with all fields ...

1 2 3
4
5
23