Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
10 views

Set / verify password using REST API

I have limited experience with both making REST APIs and implementing security features, so I figured it'd be worth running this code through some other people's eyes before making it live. My main ...
0
votes
0answers
17 views

C# ClientWebSocket implementation

I'm working on implementing websockets in my current project in C#. Could anyone please give me some pointers/suggestions for what could be improved? Specifically, I'm most unsure about how to ...
0
votes
3answers
59 views

App that sets configuration data

I've been writing my code like this for a really long time now, I am wondering if there is a more efficient way to do this. This is especially after a senior developer said my code was very amateurish....
0
votes
0answers
30 views

LDAP Authentication service. Passing UPN with password

We have a bunch of projects where users login with UPN. Multiple UPN-suffixes are available: bruce.wayne@work.com bruce.wayne@batcave.com We want to allow users ...
1
vote
2answers
68 views

Retrieve generic contract names for Managed Extensibility Framework

Edit Found the original contract name resolution by .NET MEF, the code below is not useful anymore. See response! My issue was to use existing code, to make a MEF ...
15
votes
2answers
720 views

Enforcing string validity with the C# type system

One of my biggest complaints about .NET is that there's no way to guarantee a string match a certain type in the type-system. Note This started as more of a proof-of-concept than a real usable ...
1
vote
0answers
36 views

Convert video to GIF using ffMPEG

Looking for the best way to speed up or maybe move from FFMpegConverter to another application for converting video to GIF, because it takes much time, will be much ...
4
votes
3answers
99 views

Really easy synchronised access to an IEnumerable without boilerplate code

Often when reading data from a sequence (IEnumerable<T>) in multi-threaded code, a consistent snapshot needs to be taken inside a ...
5
votes
1answer
91 views

Specialized ConcurrentLinkedList

I need a concurrent data structure with the following properties: Low overhead for enumeration Insert only at end. Removal from any point. Enumeration should be safe with concurrent writing ...
0
votes
2answers
51 views

search a given word in word file by Aspose

I implemented a function to check a MS Word document is contain a given word or not. The function will return true if filePath is contain word. Otherwise it will return false. This is my solution ...
7
votes
2answers
460 views

Generic Dictionary Equality Comparer

I created the below comparer to allow me to use a generic dictionary as a key to another generic dictionary. My GetHashCode implementation creates a hash based on ...
-2
votes
1answer
31 views

Add new TabItem to a TabControl using Click Event [closed]

I'm trying to add a new TabItem to a TabControl. The TabItem's content will be set to a new Frame, and the frame holds the actual Page. A new Tabitem is added each time the button is clicked, this is ...
1
vote
1answer
78 views

JSON serialization object with huge IEnumerable

This code is looping over polygons geometries vertices in order to create a list of deltas (distance) between vertices coordinates to compact the geometry before sending it into the web. Geometry ...
1
vote
2answers
213 views

Luhn Algorithm “modulus 10” checksum

I wanted to challenge myself in a new language that I am learning (C#) by doing a simple exercise: check if a "modulus 10" Luhn number is valid or not. In this case the common application if verifying ...
3
votes
1answer
53 views

Determining if there is data left after fetching a page of data

I just faced a problem where I needed to know if extra data was present in a given collection after a Take operation took place. Specifically, this is related to ...
5
votes
2answers
89 views

Encoding and decoding log entries in a Lossy Binary Format

One of the projects I'm working on requires logging a huge amount of information (basically, every function call). The problem is obviously that logging a lot of information has a few side-effects, ...
1
vote
1answer
105 views

Concurrent usage of resources

Please take a look at the following code. This is my attempt at understanding concurrent applications. ...
4
votes
1answer
65 views

WiktionaryBot — A Discord bot for generating Wiktionary links quickly

I'm an active contributing member of Wiktionary and an active member of an active Wiktionary Discord server. Some time ago, several users proposed a bot which would make linking to Wiktionary in ...
0
votes
0answers
48 views

Monitor (lock) in async Task

Please review my implementation usual lock for async Task context. This solution when u ...
2
votes
1answer
122 views

WebAPI global exception handler

There is a global exception handler in our WebAPI application that looks like the following: ...
-1
votes
1answer
152 views

Creating a Compatibility Shim for ExampleClass to be targeted both to .net framework and .net core 2.0

Intro: Before showing the actual code for review, let me show you an ExampleClass to create a shim for. ...
-3
votes
1answer
87 views

Best Practice .Contains C# [closed]

I don't quite know where to post this but C# is not my first language and I am hoping to get someone to nod their head or correct me :) This works but seems counter intuitive - mostly because I ...
4
votes
0answers
129 views

Custom TaskScheduler: Limited concurrency level

I'm interested in some feedback for a custom TaskScheduler implementation I wrote today for use on a game server - I wanted to be able to have a single-threaded scheduler for tasks since the game is ...
3
votes
1answer
145 views

ForEachAsync extension method (a way to run an async operation on each item of a sequence in parallel)

In a recent project I worked on we faced some issues due to an excess of parallelization (thousands of threads were created and the overall result was a degradation of performance and several spikes ...
7
votes
2answers
484 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 ...
1
vote
0answers
30 views

Simple json config provider

I'm pretty new to this so constructive criticism is acceptable. I'm trying to find any way I can improve this system, all it does is take a string, determine if that string is a web address or a file ...
1
vote
0answers
194 views

Secure password hashing implementation with salt and pepper

I share below my password hashing implementation with salt and pepper in C#, for your review and feedback. In my implementation methods like ValidatePassword(), ChangePassword() are in the user class. ...
1
vote
1answer
151 views

ChangeCalculator for calculating money denominations in change

I'm doing some exercises in OOP and I just created a program that calculates amounts of denominations in a change at the shop. So, let's say something costs 10, I give 25.30 (for some reason), so I ...
-1
votes
1answer
27 views

AppTaskWorker - Running class methods at sporadic intervals

I decided to write a class to do this for me. I had a lot of methods that needed to be invoked at sporadic intervals, across multiple projects. The dictionary will eventually be class methods, I ...
7
votes
3answers
458 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 ...
0
votes
1answer
78 views

Mechanism to retry failed requests, with throttling

I have a simple event that the client sends to the server, the server can then respond saying if it was successful, or if it failed for some reason. The client has to send a auth code, which is ...
4
votes
2answers
141 views

EnumerableHelpers: a partial implementation of LINQ for .NET Framework 2.0

Here is a static class with some helper methods for some common LINQ operations on enumerables, built against .NET Framework 2.0. This class is part of the xofz.Core98 library. Edit: a full review ...
1
vote
2answers
118 views

Creating an instance of an unit of work (NHibernate)

I'm trying to figure out how to create a NHibernate UnitOfWork using .NET Core Dependency Injection. I was just hard-coding the ...
4
votes
0answers
124 views

Comparing two instances of a class

I have a Calculation class. It is persisted in the DB and users can modify it. The aim of the CompareWith function is to ...
3
votes
1answer
47 views

Registering an event participant, using Entity Framework and several associated models

I have a method that is responsible for receiving an object and perform the information saved with Entity Framwork, using the Repository pattern. The issue is that this object is, basically, a DTO. ...
2
votes
0answers
86 views

Server app: pinging up to 500 clients asynchronyosly

TCP/IP server which controls up to 500 clients. There's a list of added computers and the server gets this list, selects computers which are not already connected and ping them using host name. ...
3
votes
1answer
63 views

Replace a^b by Pow(a,b)

The application uses NCalc to execute diverse calculations. The 'natural' way to write powers using a computer is using the ^ symbol. However, NCalc already uses ...
6
votes
3answers
1k 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 ...
0
votes
1answer
285 views

Mocking objects using abstract factory

For some time I am trying to make a mocking library for C# that mocks objects with just 1 line of code. I am using abstract factory pattern to know what is the object's type so that I can work with ...
0
votes
2answers
141 views

Add item at the beginning of each inner array in jagged array

So, there is a big jagged string array (~ [120] [1 000 000]) here that represents data from an excel worksheet ( columns / rows). Task: We have to append items at the beginning of each inner array. ...
8
votes
2answers
1k views

Replace all the occurrence of a string

I have the following function to replace all the occurrence of a string that matches certain token. ...
10
votes
3answers
158 views

Generating image gauges from a value, min and max

One of the things I was recently investigating was the ability to generate "gauge" charts—that is, a chart which shows where a value stands within a range of values. As an example, if we know ...
1
vote
2answers
110 views

ADO.NET DAO Layer Design With Base DAO

I have a database with a number of stored procedures. These stored procedures provide the basic CRUD operations against the data. I'm trying to create a DAO layer with separate DAOs for each domain ...
2
votes
2answers
104 views

Substring a String from given start index and given substring length

I want to substring a String from given start index and given substring length. if the string is empty then returns String.Empty if the string length is greater than start index then it substrings ...
0
votes
2answers
83 views

Pull From Oracle into CSV File

I have written this code in C# to connect to an Oracle Database, omitting the tnsnames.ora file, then place results from a query into a CSV File. Is there more efficient way to do this? (Such as ...
4
votes
1answer
285 views

From production to staging

The story here is about a console application that replays to a test system string clauses already imported in the production system. Looking forward to your comments. ...
5
votes
2answers
2k views

Rounded borders for different controls (Button, TextBox, ComboBox) via Attached Property

Suppose you just want to set border radius for different controls: Button TextBox ComboBox ...
9
votes
6answers
2k views

Loop months between a time span yyyy-mm and yyyy-mm

I'm trying to come up with a more elegant solution for a loop in months that I wrote long time ago in C# 1.1 I use a helper class Month but I'd prefer to get rid of it and make the code shorter and ...
2
votes
1answer
91 views

A simple TicTacToe

A simple game of TicTacToe. Please review for style and other. Is this a proper ViewModel? ...
3
votes
3answers
612 views

Compare two Lists element-wise containing reference types

I am trying to compare two lists containing reference types (custom classes) element-wise, ignoring order. My question relates to the Equals method as shown below. ...