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
2
votes
2answers
2k views

SqlCommand ExecuteReaderAsync helper method

The following helper method executes commands asynchronously and returns a Task<IEnumerable<T>> where T is a type that receives the row information from ...
1
vote
0answers
548 views

KDF computation using CMAC with AES (as PRF) using Bouncy Castle C# library

Using bouncy castle .net implementation (version: 1.8.1.0), I am trying to create an encryption key from a known master key using a key derivation function. The NIST Publication 800-108 contains ...
1
vote
0answers
77 views

Loop through records, change property of records, send mail for each

I am trying to basically do the following Get record from db. Loop through records and send mail out for each record. Update database records. I would like to know what is the most optimal way to do ...
2
votes
0answers
231 views

Customizable Blockchain's block structure

I'm creating a new open-source blockchain framework for .NET Core and .NET Standard. But I have some questions about how to make block structure to be customizable and look beautiful. Let's begin ...
1
vote
0answers
56 views

The Login Authentication Model Class for ApiController

This class accepts input parameters (Login and Password) from ApiController via ...
4
votes
1answer
130 views

Rare binary numbers

Rare numbers are the natural numbers in their binary forms in which there aren't two (or more) ones next to each other. Make a program that will give the N. rare number! For example: In case of N =...
2
votes
2answers
1k views

C# Extending the DispatcherTimer - Intermission timer

I'm working on a WPF project where a timer with Pause/Resume functionality is required. The standard Windows.Threading.DispatcherTimer doesn't offer that, so I ...
0
votes
2answers
3k views

Set Label content and make it disappear after 5 seconds

Let's say I have a label and a button. If I click the button, the label is set to some text, say "hello, world!", and after 5 seconds, it should disappear. Easy enough, right? I have the following ...
2
votes
1answer
709 views

Creating a shortcut class in C#

I'm working on making a shortcut... manager, if you will. It will be reused throughout the rest of the application for registering types that can later be resolved into views. I have a rule that the ...
3
votes
0answers
344 views

Extension methods with reusable logic - passing Action to Func<TResponse>

I have several extension methods for interacting with the Google Calendar API, and these all use an ExecuteWithRetry function for wrapping API calls within retry ...
15
votes
6answers
15k views

Determine if an image is opaque or transparent

I wrote an extension method defined for the Image Class (System.Drawing) — which returns a Boolean value telling you if the image is opaque or transparent. The color of each pixel in the image is ...
1
vote
3answers
2k views

Simple web service call with retries

This code is actually pretty basic. Basically, I'm doing a large number of web calls. I currently do up to 3 Web Service calls simultaneously, one of which is below. There were 3 errors I saw in ...
3
votes
4answers
142 views

Multiplying/Dividing before Adding/Subtracting

I'm working on a calculator for educational purposes and was asked to include a rule that multiplies/divides before it adds/subtracts. Let's assume I have the following equation: ...
2
votes
0answers
942 views

Adding support of HTTP PATCH

I have an API endpoint to modify a race car, which supports the PUT method: PUT /api/racecars/{racecarId} Since PUT must be ...
3
votes
2answers
155 views

Getting a serial number from shared table

I have a table that keeps track of a global serial number shared between several tables. This is not the PK or unique id for each table. It is like a case identifier. Every time users create a new ...
2
votes
1answer
611 views

TPL Task tracker which keeps track of tasks

This class keeps track of tasks which are added and tries to remove them after certain delay. I tried doing it with CustomTaskScheduler but didn't get much in return. Here is my related question on ...
5
votes
1answer
4k views

Generate video thumbnail

I wrote a simple, yet disgusting video thumbnail image generator method—which uses the MediaToolkit .NET library. The code is not self-explanatory whatsoever, and it's extremely inefficient. It ...
4
votes
3answers
499 views

Parse a stream of space separated numbers

I need to parse a stream of characters IEnumerable<char> as a list of space (and newline) separated numbers. Numbers can be expressed in base 10, base 8 (...
1
vote
0answers
1k views

HTTP PATCH method for WebAPI

I'm working on an implementation of the HTTP PATCH method for WebAPI. I know there are packages like JsonPatch and OData Delta for that, but they don’t work for me. JsonPatch is too complicated and ...
6
votes
2answers
579 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 ...
1
vote
2answers
510 views

Common Sorting Algorithms

Here I've prepared my solutions for the following algorithms, and was curious if there were a way to optimize any of them. Any input is welcome and appreciated! ...
2
votes
1answer
72 views

Generating different numeric sequence based on user input

I have the following task at hand and I have completed it and it is working fine. Since I am new to design patterns, I would like to take your opinions on how I can improve the code quality in terms ...
2
votes
0answers
568 views

C# FileSystemWatcher Manager with Debounce

For a class last fall I was working on a "cloud backup" system. Originally in Pascal, I decided to rewrite it in C# and expand the feature set. Below is the FileSystemWatcher "manager" class which ...
0
votes
0answers
50 views

Extract value from a database and populate objects

I have a database, with some history data for a lot of tags (ie. measurement points in the plant). Users supply a calculation script, and get the result of the calculation as a result. The main ...
2
votes
1answer
201 views

Building a very basic calculator

I have been a VB developer for couple of years, but strictly using functional programming paradigms — I just started using object-oriented paradigms a few days ago, and want some advice on how ...
3
votes
1answer
169 views

Exposing .NET's internal StorageRoot via Reflection for accessing file/stream-based Structured Storage

.NET tantalizingly exposes StorageInfo and StreamInfo as public classes, but hides the ...
5
votes
1answer
6k views

Encrypt and decrypt a message using AES-256 with GCM mode using Bouncy Castle C# library

Goal: Given a plaintext message and 256 bit key, encrypt (and subsequently decrypt) the message using a 12 byte IV (in this case null bytes for simplicity, should not do this, I know) with MAC of ...
4
votes
1answer
133 views

Binary search for a missing or default value by a given formula

An application I've been working on for a while needs a manner to find a missing element from a sorted array, the problem with the application is that these values aren't numeric. They have a formula, ...
0
votes
1answer
890 views

Email Sending Application

So this is an automatic email sending application, it reads with Handlebar the email templates and assembles them, and then sends the email classes. My goal with the code is to make it as easy to ...
4
votes
3answers
267 views

Determining the region from several sources of information

The task is to determine the region by comparing three sources of information taking into account the coefficients of their importance. ...
0
votes
1answer
70 views

Simple property formatting

In a VB.Net class, I have an method that replaces all square brackets [] in certain properties by normal brackets (). Edit: The ...
2
votes
0answers
71 views

REST API design to handle status migrations

I have a requirement to provide an API which would allow to change status of Order. The API is supposed to follow REST principles, so I have designed an endpoint ...
2
votes
2answers
108 views

Two maximal value in array. Sorted and Array.Sort()

Compare the two methods of sorting the array in ascending order, where can I optimize? How best to handle exception handling? ...
2
votes
2answers
81 views

How to avoid code duplication in ordering system

Here is the piece of order system. And this is hierarchy of order classes in this system ...
-1
votes
1answer
2k views

If and else without curly brackets [closed]

Is it possible to have an if condition with curly brackets and else conditions without brackets? Also what is the good practice to format it , should there be a new line after else keyword? ...
6
votes
2answers
425 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" ...
2
votes
1answer
99 views

Marshaling to a complex structure in .net

This is a follow up from question https://stackoverflow.com/questions/45106245/net-file-random-access-recoard-locking I have been able to make the reading and marshalling work ok but the performance ...
2
votes
1answer
1k views

Project Euler 19 (count Sundays in the 20th Century) with a while loop

I'm working on Project Euler problem 19, which reads as follows: You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. ...
2
votes
0answers
55 views

Updating Excel sheet with information from a DataTable

Basically, I'm trying to update an excel sheet using a DataTable (The columns structure between the two are not the same) with respect to the following rules: ...
6
votes
1answer
2k views

Railway Oriented Programming (ROP) in C#

I am not sure if there are good ROP implementations already existing in the open because I couldn't find any, actually I found one by odytrice (https://github.com/odytrice/Operation), but I think the ...
2
votes
2answers
119 views

Comparison of 2 values based on custom operator

I am working on a library that parses query strings and evaluates the result for a given context. The query has the format FIELD OPERATOR VALUE (AND|OR) .... The ...
2
votes
1answer
91 views

Mailsending application for e-store

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" ...
1
vote
1answer
147 views

Brute-force-like solution to Project Euler Problem 5

Project Euler problem #5 is the following: 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that ...
3
votes
1answer
499 views

E-store automatic email send, to be run daily

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 ...
0
votes
2answers
122 views

User and group management access to main class

UserGroup is not the main class. I don't really mind putting these classes in a class as they are related. I would still like to break them out. Problem I have is if I put ...
1
vote
2answers
299 views

Manage Users and Groups

This is part of a document management application that is in a prior question. Manage users, roles, and groups. A user can have only one role but they can be in many groups. There is join struct ...
-2
votes
1answer
166 views

Document Management Properties and Searching

This is the 'middle-ware' for a document management application. A document has properties which describe it, and allow users to search for it. The server will interact with the database, and the User-...
5
votes
0answers
181 views

WebPage LogReader class - Parallel DNS w/timeout for computer IP's and domains from log scrape

This is a namespace to read a bunch of events from a log file and display them in a table on a webpage, some additional data (computer domain and IP address) is also pulled in from DNS. I am mostly ...
12
votes
3answers
10k views

Function to find a certificate in either the user or the machine store

I wanted a function that would return a certificate, given its serial number, regardless of which store it is in. It has to do almost the same exact thing but twice (once for each store). To keep it ...
9
votes
3answers
577 views

LINQ-ifying Colour Generation from Strings

Recently I was thinking about how Google, Microsoft Outlook on Windows Phone (and now many others) method of giving you a coloured icon with a letter in the centre of it works. Essentially, given ...

1 3 4 5 6 7 22