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
7
votes
1answer
715 views

Implementing an IRC Bot

This is a (fairly) simple IRC bot. The whole idea of it was similar to Duga, except that it will post to an IRC server instead. The bot takes messages from a SQL table and posts them in the IRC ...
7
votes
1answer
2k views

Replacement string Base64 (and a Base32) conversion [closed]

This provides (my own) implementation of ToBase64String and FromBase64String (since the .NET implementations suck), and a ...
7
votes
2answers
818 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 ...
7
votes
1answer
18k views

Making async SQL calls

I've written a class to make async SQL calls and it appears to work like a charm! But I'm a bit concerned about what it means to send a lot of queries to the server and then aborting them by throwing ...
7
votes
2answers
4k views

Implementing IDisposable correctly to return TCP connection back to pool

I'm trying to implement TCP connection pooling and return a connection back to the pool using IDisposable. I'm wondering if my implementation is correct. It seems ...
7
votes
1answer
445 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)...
7
votes
1answer
6k 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 ...
7
votes
1answer
78k views

ASP.Net, C#, and alert/display messages

We have a hidden div in a master page. When we want to display a message, we send a function a message to display, and it turns that div from .Visible false to .Visible true, and fills the div with ...
7
votes
3answers
1k views

3-layer ASP.NET app - Need critique/advice

My current setup is a 3 layered application: UI > BLL > DAL. Each layer is set up as a separate project. The UI is an ASP.Net website and the BLL & DAL are Class Library projects. I've shown some ...
7
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 ...
7
votes
1answer
1k views

A super string cleaner

I need a method that clean up a string considering these few rules: Remove or not Spaces Remove or not Special Chars Remove or not Numbers Descaptalize or not the string (this is don't really needed ...
7
votes
3answers
428 views

Secure password hashing implementation

I'm implementing a password hashing method for a website. The code below is part of the User class. Any pointers on what I could do better? ...
7
votes
1answer
5k 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 ...
7
votes
3answers
2k views

Cached empty collections

I often need to return empty collections. One of those days I wrote the following to return a cached instance: ...
7
votes
1answer
330 views

MVVM: Am I doing it right?

I read a lot of articles recently concerning XAML, WPF, data binding and MVVM. I also watched some MVVM tutorials and downloaded some MVVM samples. I finally got my first MVVM sample to work, but ...
7
votes
1answer
27k views

Navigation between pages in WPF MVVM application

I did a project in WPF MVVM. Just a single Window with single Frame control and few Pages. My problem was communication between ...
7
votes
1answer
992 views

Encryption and decryption on streams using AES CBC + HMAC SHA

The goal of the code below is to: Support authenticated encryption using AES in the CBC mode and using HMAC SHA. Support encryption and decryption of data of size larger than memory (potentially). ...
7
votes
1answer
96 views

Streaming a Pin functionally(ish)

Earlier today I wrote a question (Validating a StreamingPin) and I thought it was a good idea (apparently I was the only one who thought so, but whatever), so I proceeded further with it and developed ...
6
votes
6answers
13k views

Validate that a given string (name) meets certain requirements

...
6
votes
2answers
553 views

Parse a specified arithmetic type from string

This class has the responsibility of parsing a string to one of the primitive types: int, double, ...
6
votes
5answers
31k views

Faster way of reading csv to grid

I have following in Windows Forms .NET 3.5 It works fine for csv with records less than 10,000 but is slower for records above 30,000. Input csv file can can any records between 1 - 1,00,000 records ...
6
votes
2answers
685 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. ...
6
votes
6answers
6k views

Code to initialize a .NET object from a CSV file

I am initializing the following object from a CSV file: ...
6
votes
3answers
3k views

Implement `Dispose` method in C#

I have a class: ...
6
votes
3answers
2k views

C# version of C++ shared_ptr

I need something akin to C++'s shared_ptr. Essentially I need an IDisposable item that I can ensure is cleaned up as soon as possible once all references have been removed, but this resource will be ...
6
votes
3answers
31k views

Sorting a list based on date and time

I have a class that is used to basically store samples from data being read from a system. Within that class is a property that I use to store the date and time of that sample: ...
6
votes
5answers
12k views

Find most occurring word in a txt file

Assume that we have a .txt file that has one word per line. Find out the word that occurs the most. Here's what I was able to write (I used array of strings ...
6
votes
2answers
9k 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. ...
6
votes
2answers
10k views

Processing a large number of files in a folder

I have a folder which contains lots of files. I need to write C# code that will open and read and display the content of it. Is this efficient code or should something be changed? ...
6
votes
3answers
422 views

From a list of lists to a single object

Long story short a user can have things in common with another user, but I don't what to show more than 4 main categories in common, only the first 4, the priority is the order in which the lists are ...
6
votes
3answers
3k views

Generic getting single value from DB in C#

Few months ago I posted my code Getting a single value from the DB. I implemented suggested changes and this is how it looks like right now: ...
6
votes
3answers
13k views

.NET REST API JSON Filtering

My question, REST API and lazy loading objects, didn't receive any answers (or many views), so here is my attempt at the solution. Problem overview: My mobile app requests a list of objects through a ...
6
votes
1answer
3k views

Concurrent HashSet

I've recently been using HashSet and locking on each method, I found this to not only be a lot of work (was using it in a lot of places) but I started to see inconsistency in my code. I later decided ...
6
votes
2answers
131 views

A simple program which returns specific value from array

After researching for an hour regarding SOLID Principles, I tried to do it myself. Please note that most of these codes were from the ideas of others. I created a simple program which returns ...
6
votes
2answers
528 views

Sending a Torrent magnet link using the Deluge JSON API

I have built this script that sends a magnet link to the client. As I never ever had any proper programming lessons I would want to ask you if this approach is good, if I am missing something, There ...
6
votes
2answers
95 views

Calling functions with different variable types

I need to call the function that will get the value of a datatable cell with the ColIndex, either a text (column name) or an integer (...
6
votes
3answers
765 views

Time Machine service

Recently I had someone describe a "Time Machine" service to me; that is, a service that could be used to change how a chunk of code perceives time. Normally through calls to DateTime.Now and other ...
6
votes
2answers
18k views

AES Encryption C# .NET

I have written a tool for encrypting string using the AesCryptoServiceProvider in .NET. The folllowing parameters are used: Block Cipher Mode: CBC Initialization Vector: 16 bytes (randomized per ...
6
votes
5answers
1k views

C#/.Net 4.5 - Number Guessing Game

I'm currently enrolled in an introductory C#/.Net 4.5 course and one of the things I want to focus on is the quality of my code. This is the first assignment our instructor had us do, the ever-...
6
votes
4answers
1k views

Conversion helper with support for enumerations and Nullable<T>

I recently wrote this code as a more versatile stand-in for Convert.ChangeType. I have a nagging feeling that there's something I might be overlooking, or that ...
6
votes
1answer
5k views

Reducing memory footprint of ReportViewer

We have implemented a process using C# and ReportViewer to create PDFs by the LocalReport.Render method. When we have to process ...
6
votes
4answers
6k views

Function to test if the current time is within a time window

I have written the following code that tests if the current time is within a time window. It seems to work ok with my test cases, but I would be interested if anyone can see any possible problems or ...
6
votes
2answers
478 views

Validate a password mostly to NIST-2017 standards

I have an application that needs to validate user passwords to a very reasonable custom validator, which is heavily based on NIST-2017 requirements. The validator intends to satisfy the following ...
6
votes
4answers
3k views

Splitting a string on delimiter outside of quotes while returning item-by-item

One of the more recent functions I've needed for personal and work purposes is to split a string on a delimiter, but while ignoring the delimiter when inside a quote. Just as well, if within a quote ...
6
votes
2answers
327 views

Optimizing special cases of modulo

I have a use case where improvements to the speed of calculating modulo for 64 bit integer dividends makes a significant difference in overall processing time. The divisor isn't known statically - it ...
6
votes
2answers
591 views

First simple multithreaded application

It's been quite some time since I got my eye on the multi-threading, today I decided to create a really simple application which runs 2 while loops simultaneously and prints the current progress of ...
6
votes
2answers
420 views

Automatic Email Script/Program for fictional e-store C#

This is a fictional email sending program for a e-store I've done for practice purposes. EmailSenderProgram is a program sending emails to customers. Currently it sends two types of email: "welcome" ...
6
votes
2answers
605 views

Search on List<Tree-like structure>

I create a data collection system that has a tree-like structure built on the similarity to the pattern of the factory, and I have the difficulty in working with this structure, more stingrays lot of ...
6
votes
2answers
2k views

Recursively merge dictionaries with generic types in C#

I am looking to implement a method that is capable of merging 2 dictionaries using generics. I've seen several great answers on SO already, but none handle the case of nested dictionaries. As in, what ...
6
votes
3answers
20k 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 ...