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
400 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
305 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
603 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
299 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
8k 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
5k 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
122 views

A simple TicTacToe

A simple game of TicTacToe. Please review for style and other. Is this a proper ViewModel? ...
3
votes
3answers
1k 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. ...
2
votes
0answers
696 views

Parsing XML file from the REST API

Please suggest how I can improve my code (like memory leakage, which pattern to use etc.). I have to parse a book XML in two ways: first from an FTP file and second from the REST API. I implemented ...
0
votes
2answers
80 views

Custom Comparison at the object

This question is NOT about passing a Comparison to a Sort. The question is how to pass a Comparison to an object for object to object (1:1) Comparison. Some users must be able to pass in a ...
3
votes
2answers
580 views

Find all the positive divisors of a positive integer

This came from this question. Find all the positive divisors of an integer >= 2. Can stop when i * i >= number. Please review for speed and style. ...
1
vote
1answer
750 views

Schedule matches for a season or round robin tournament

The algorithm comes from wiki. The output from the algorithm is correct but not something that a person could (easily) understand. See the wiki link above. Each team play every other team. ...
0
votes
1answer
556 views

Simple logger class in C#

I've been using logging libraries recently and somebody told me to try and write my own. I've kept it minimal but the only drawback is I can't log in static classes, due to TClass. Follow-up I'm ...
4
votes
0answers
36 views

Validating a collection of proxy servers with maximum possible throughput

I am validating a collection of proxy servers and trying to achieve the maximum possible throughput. I've tested a few different methods, such as Task.WhenAll, TPL ...
1
vote
1answer
107 views

Release the acquired lock after specific timeout

I'm trying to release a lock after some timeout. The lock is acquired to do any database changes so that multiple requests will ...
7
votes
2answers
11k 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. ...
5
votes
2answers
128 views

Combining SQL Tables into One Table in New DB with Similar Fields

I have a SQL Server Database filled with Reports all having the same schema. What I've done is created a .NET application to automate the process of adding all reports to a new table. How can the ...
5
votes
2answers
260 views

Combination and factorial

Combinations is how many ways to take k elements from n element. Combination is different from permutation in that order does not matter in combination. Combination is used a lot in poker ...
18
votes
8answers
2k views

Counting elements meeting a predicate in an enumerable without iterating the entire sequence

I was reading this question, and the answer that mentioned streams, and a thought had occurred to me. In many cases (at least in my usage) I want to determine if a sequence (or ...
4
votes
2answers
543 views

Populate null fields in an object through reflection

I have recently implemented this utility class for going through an instance's member fields recursively and assigning them default values if they are null. Here is the implementation in the ...
2
votes
2answers
542 views

Game Character class with many skills

Im creating a class that has all of my data in and can see it would quickly become messy. I feel that there must be a way of making it neater rather than making a new method each time For example. I ...
6
votes
1answer
755 views

Retry mechanism for failed downloads

I'm writing a mechanism to retry any failed downloads that respond with certain http error codes, I've noticed the server I'm downloading from will unexpectedly throw these codes to me and when I ...
4
votes
1answer
91 views

Handling a single connection to a server or client

I'm writing an asynchronous TCP server and client for a game in C# and in particular getting sending right is a bit tricky because calling BeginSend() before ...
3
votes
2answers
6k views

“Always stay connected” mechanism for socket connection

I'm calling Connect() for the first time I connect, I am then checking if the connection is still connected every 10 seconds if it is not connected it attempts to ...
3
votes
1answer
2k views

Memory cache implementation with a static class inside a normal class

I'm trying to implement a cache available in a data provider (repository). The data provider is a normal class, instanciated at every request made to the application. The reason I have a static ...
6
votes
2answers
567 views

Finding MinMax values and returning a tuple as a result

I was coding some tooling stuff when I started to ponder whether the best return type for a Range / MinMax method applied on a IEnumerable method. I am using the value the C# 7 Tuples like below, but ...
2
votes
2answers
116 views

Returning a collection inside of an IEnumerable method

The following scenario came out of a discussion I was having with a fellow developer on this project. He likes to execute an Ienumerable as soon as possible, hence ...
7
votes
1answer
1k 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). ...
4
votes
2answers
136 views

DDOS Mechanism: Improving thread safety & loop speed?

I'm pretty new to this but I coded a DDOS mechanism for educational purposes. I need to know if the thread safety can be improved (Right now I have none, but do I need any?) and if the loop speed can ...
1
vote
1answer
120 views

Custom observable types and their supporting classes

I decided that for some parts of my project, communication through events would be very handy, for that purpose I started writing the most basic part of the event system, an interface consisting of ...
3
votes
1answer
4k views

Simple timer start and stop from console

Just a simple timer application for review. Stop and start the timer from the command line. The plan is to use this in a poker application to fold out a player if they don't act after a time ...
3
votes
1answer
107 views

Poker server as a service

This is very simple poker server. Target is a REST server. In real poker you do not act until action is on you (well you are not supposed to). On a server it is nice to accept action (bet, call, ...
5
votes
2answers
1k views

Custom enumeration classes

Lately I've been using a lot of enums in my project and the lack of generic Enum constraint seems to be quite problematic. This combined with few other headaches ...
3
votes
3answers
162 views

Singly-linked list queue

I recently learned the core .NET Queue type uses arrays internally, and that this is actually much more efficient. I've had a go at writing a singly-linked list ...
3
votes
0answers
167 views

Object pooling in WPF

In a WPF project I'm working on, often multiple objects reuse the same AnimationTimeline, to smooth that out I made an ...
11
votes
1answer
114 views

400 line method to cycle the movement for players in my game

I use this method to cycle the movement for players in my game. I've been told this method is too large and needs to be cleaned up into smaller pieces, I really can't see much that shouts out "put me ...
4
votes
1answer
69 views

Processing game user movement

This code is a cycle method. It gets ran every 500 milliseconds to process the movement for users in the game. I've been told that it's been poorly coded and could use some optimizations but they didn'...
8
votes
1answer
852 views

MVP Passive-View

First of all, I'm really new to the MVP design pattern (Passive-View) and I've been trying to implement it in a WinForms application. Before I'm going any further, I'd be very happy if you guys can ...
4
votes
3answers
529 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
100 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
7k views

Code to initialize a .NET object from a CSV file

I am initializing the following object from a CSV file: ...
3
votes
1answer
769 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
529 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
342 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
208 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
65 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
82 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 ...