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
4
votes
3answers
567 views

Console word wrapping

I wrote a text adventure game a while back and today I looked at it to see how I did the word wrapping (to use in a new project); I'm curious if I went about it the right way. I realize I could use an ...
2
votes
1answer
101 views

Find sum of 3 that total a target from a List

A related Java question got me curios. All unique combinations (not permutations) of 3 values that sum to a target from a list of integers. Values can duplicate in the list but are only used once. ...
-1
votes
2answers
79 views

Improving predominance for updating 40000 records using entity framework [closed]

I have Two tables Circuit and Tag, Circuit ------------------ Id Name Path Tag ----------- Id Name Circuit_Id Now I have to loop through all the tags and ...
6
votes
6answers
8k views

Code to initialize a .NET object from a CSV file

I am initializing the following object from a CSV file: ...
3
votes
1answer
889 views

Implementing RecordSet-like class in C#

From the outset, let me state that I'm working with some older technology. I'd rather use Entity Framework, but I have to use what the client is using if I want to get paid. I am converting some old ...
10
votes
6answers
2k views

Poker dealer Hold'em

This represents a table (server) for Texas Hold'em. This is not a full Hold'em game but it is working code for what it does. It shuffles, deals the hole cards, deals the board, moves the blinds, and ...
3
votes
1answer
589 views

Regular expression to parse guid and other attributes

I have this regular expression that extracts guid and couple of other attributes like name, type and version. Please review the regex for any optimizations and improvements. Strings are always in the ...
2
votes
1answer
88 views

Event based input files management system

I'm currently making a system that can accept different sorts of files and some classes are interested only in specific types of files, while some don't discriminate at all. Note Type of file isn't ...
1
vote
2answers
375 views

MySQL database wrapper

Here is a wrapper to a MySQL connection. First I have a DatabaseController and then a DatabaseConnection. How I use this is ...
3
votes
1answer
227 views

Game Packet System

Usually I'll have around 200 packets, but for the purpose of this question I've only include 1 packet in the code, the rest is the same principle as if there was still 200. Here is a packet system, ...
3
votes
1answer
66 views

Wrapping third-party component to use in windows service

I'm using a third-party commercial server component to listen for SAP IDocs. I want to run the server inside a windows service and the vendor recommends having a separate method to check the server ...
2
votes
2answers
83 views

Limit and merge saving operations

Use case: I want to automatically save data in the storage when a property of an object that implements INotifyPropertyChanged changes. Therefore I subscribe to the PropertyChanged event and call a ...
1
vote
1answer
434 views

Vertical & Horizontal Direction of a DataTable

I wanted to have a DataTable with cells in direction that is top to bottom or bottom to top and left to right or right to left. LR - LEFT to RIGHT RL - RIGHT to LEFT BT - BOTTOM to TOP TB - TOP to ...
1
vote
0answers
66 views

Tiny app to track working time on Jira tickets

I'm a .NET intern. For my project management we work with Jira and we have to track real working time on a ticket to log the work and compare it to the original estimate. For this purpose I have ...
2
votes
0answers
66 views

Convert Simple C# Console>Service to perform repeated API calls and file system actions [closed]

I was sent here from StackOverflow, as it was indicated that the quality of my current approach may have been questionable. I'm attempting to transform a simple console application so that it may be ...
2
votes
1answer
2k views

Service Layer, using Entity Framework 6.2

I would like you to review a part of my warehouse application, a Service Layer to be exact. The architecture of the program is: DB --> .Data (EF's DbContext/...
6
votes
1answer
597 views

Simple change tracker for POCOs

Problem I have a list of POCO model objects (approximatly 1.000 to 10.000) and I want to track changes on them: Check if at least one of the items has changed (to show the user that something ...
2
votes
0answers
246 views

Console shutdown mechanism [closed]

I'm trying to create an effiecent way to shut down my console application. To do this I have a while loop in my program's main method waiting for a request to shutdown. ...
-1
votes
1answer
56 views

Measuring class load times with utility method [closed]

When ever I load a new class I measure the time it takes to setup, initializing and load that class, it helps me debug the time it takes to complete actions within my application. Here I have a ...
0
votes
1answer
2k views

How to optimize a nested foreach loop which is creating same data object (with different values)

I have following code which gets MastrSegments from repository(entity framework). It's working but I think I am violating DRY (though not sure). MastrSegments conatins collection of SegReqs and ...
4
votes
2answers
4k views

Configuration class in C#, reading an INI file

This class will load a file with INI configuration elements and cache them, it then has a method to get an item from the cache if it needs to. ...
2
votes
0answers
1k views

Entity Framework with two databases (with UoW, Repository and Service Layer)

I have two databases: one for a warehouse, second for the office (The db design is out of the scope of this question). There are MANY cross-database funtions. One of those functions is ...
4
votes
1answer
245 views

Generic class for Unit of Work pattern

In my project I use the Unit of Work pattern and it works really well. The implementation is the following: ...
4
votes
1answer
1k views

Running a collection of BackgroundWorkers one after the other

In my project, I had three BackgroundWorkers that can be run independently, but I also wanted to allow the user to "Run All" of them, but not at the same time. They ...
1
vote
2answers
82 views

String to class variable initializer

I have a piece of code that takes a string array with 'key/value' pairs split with a ';' and finds the type of each variable and initializes the variable to the value given. The code given works as ...
5
votes
1answer
859 views

Parsing a string using a regex and doing a mathematical calculation if there is a match

This is my first time writing anything in C#/.NET. I have written a simple function that takes a string, splits it, compares each split value with a regex and if it matches it'll take the second part ...
2
votes
1answer
600 views

Quest System in C#

I have created a quest system for a sort of game. The users will be able to complete quests by doing simple things and in return earn rewards for completing them. Handles everything quest related <...
3
votes
1answer
119 views

Group System in C#

I wondered if someone could give me some constructive criticism on my group system? Holds the badge parts for groups. ...
1
vote
2answers
109 views

Slowed Data reader in C# [closed]

I am writing code to update data in the sample table (i.e. stbl) atoms of a video/audio file and found that in my method UpdateValues slows down to almost a crawl ...
4
votes
1answer
5k views

Updating WPF image from camera frame grabber thread

I have created a WPF application in .NET 4.6.1. to display video from the frame grabbing event for a machine vision camera. In XAML there is an image control bound to a WriteableBitmap ...
5
votes
1answer
9k views

Factory pattern along with DI using Unity container

I am learning design patterns and this is my sample code where I have implemented Factory pattern and instance creation I have delegated to Unity container Framework(DI) to build the loosely coupled ...
8
votes
2answers
6k views

Copy a similar list to another

My code works fine and I am just wondering is there a more efficient way to copy a similar list to another and ignore the properties which are not present. ...
10
votes
1answer
2k views

ResettableLazy<T>: a resettable version of .NET Lazy<T>

I implemented a resettable version of .NET Lazy (context: mostly to use it in a MemoryCache for auto refresh purposes on item expiration) This is a very naive implementation and I am pretty sure ...
1
vote
0answers
92 views

Thread-safe hashset that enumerates according to insertion order

According to the .NET documentation, HashSet<T> does not maintain order when enumerated so I implemented my own using F#. Can anyone help review if this is ...
1
vote
1answer
154 views

How to combine items in List<string> to make new items efficiently

I have a case where I have the name of an object, and a bunch of file names. I need to match the correct file name with the object. The file name can contain numbers and words, separated by either ...
3
votes
0answers
1k views

Cancel running Task on Dispose and race condition

I'm building a wrapper around NamedPipeServerStream and NamedPipeClientStream. Currently my ...
1
vote
1answer
888 views

Generate c# classes through XSD.exe automatically based on embedded resources in assembly

This program is supposed to take every embedded XML Schema file in an assembly and generate classes in the csOutPath. The names of the classes and files should match the stored schema and be put in ...
4
votes
4answers
13k views

Get the brightest rectangle within an image

I wrote an extension method for bitmaps which finds the brightest rectangle (with specified width & height) within an image. Hopefully my code comments eliminate any confusion. If not, please let ...
3
votes
1answer
72 views

Subscription handler

I have so many classes like this in my solution but I've chosen this one just to show you guys what I mean by it. In my solution I have lots of classes that just follow the same 2 classes exactly the ...
8
votes
1answer
4k 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 ...
1
vote
0answers
182 views

RSA Encryption, improving programming practice and code quality?

This was my first go at any kind of encryption in any kind of programming aspect but my application needed some kind of RSA end encryption for my game packets. Uses RSA and diffihelman and runs off 3 ...
2
votes
0answers
83 views

C#: Foreach vs Seperate Threads?

Each 'Room' class instance needs to call the method 'ProcessRoom'. I am currently overthinking something and would like another persons opinion. One of the constant things here is ProcessRoom gets ...
1
vote
0answers
68 views

Task/Thread/Timer Dilema

I'm looking to improve the performance, quality and effiency of the following code. I have a server I use for my game that manages all the players connected plus a few other things, which have Manager ...
1
vote
1answer
126 views

Managing player data

Here is a code example from my name, where I use a MySQL db and store players data. In this code I'm using a DataReader when loading and saving the data in and out....
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
517 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 =...