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
107 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
80 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
416 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
82 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
751 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
48 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
1k 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
113 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
88 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
136 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
495 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
290 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
160 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
175 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
8k 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
520 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 ...
2
votes
1answer
730 views

Converting a JSON object to XML to be passed to an ASMX webservice

What I have is a scenario where we need to be able to call any ASMX web service and pass any data structure to it that has been constructed on the JavaScript side. Until now, I have been creating ...
4
votes
2answers
422 views

Count sort implementation

Is this a proper Count sort implementation? Code and style improvements? It does not support negative and that should be improved. A large input could cause out of memory. Some of the array index ...
0
votes
1answer
159 views

Validate Czech Birth number [closed]

I will not go into depth as for how Czech Birth number should exactly look like. It is kind of similar to insuarance number, example: Let's say a valid Birth number may be e.g.: ...
1
vote
2answers
513 views

Selection Sort Implementation

Is this a proper selection sort? Any code issues? ...
0
votes
1answer
90 views

PCR analysis on data imported from Excel

I'm writing a program that is going to analyse some data imported from an Excel spreadsheet. It is currently running quite slow (couple seconds on an average machine) and I was wondering whether it ...
2
votes
0answers
2k views

Generic repository and generic service

I use the Repository/Service design pattern in my projects. I have doubts whether it is worth using common services BaseEntity: ...
5
votes
3answers
416 views

Determine objects to delete from a database

I have the following method which determines which cars I need to delete from the DB. ...
4
votes
2answers
2k views

Make change for a given amount given denominations

Make change like at a cash register Input is the denominations of the currency and the sum In test case only coins are entered Return how many of each denomination Return the fewest possible ...
5
votes
1answer
421 views

Splitting a UTF-8 string into equal-sized byte-arrays for parallel processing

Based upon a question from Stack Overflow, I wanted to expand on the answer I wrote and define a solution that would support ordering the strings (after processing). So this starts off with a basic <...
1
vote
3answers
1k views

Two circles intersect

Do two circles in a 2D plane disjoint? $$(r_1 + r_2) \cdot (r_1 + r_2) \gt \Delta{X} \cdot \Delta{X} + \Delta{Y} \cdot \Delta{Y}$$ Any comments / corrections on this code? ...
4
votes
1answer
217 views

Component-based system for animals

I'm making a small Zoo application, in this question I will cover only the basics - the animals. I've picked the component-based design over inheritance because the creatures can be quite complex ...
-2
votes
1answer
249 views

Improvements for this Rounding Method [closed]

This is used to round to any desired quarter, half etc. Is there any improvements that can be made for performance, unforeseen roundoff issues etc...? ...
2
votes
2answers
350 views

Console single player blackjack versus a dealer again

This is the second pass on this. pass one A single player versus a dealer. It does not perform bets - it only track wins and losses and has no splitting. Other than that I tried to get it all in. I ...
2
votes
1answer
596 views

Tree containing different data types [closed]

For a while I was thinking of a way I could have multiple objects of different types that related to each other be included in a tree. For example, say I have CEO, Manager, Representative which all ...
1
vote
1answer
2k views

Single player console Blackjack game

This is just a single player versus a dealer. I'm not worried about execution time. It does not perform bets - it only track wins and losses- and has no splitting. Other than that I tried to get it ...
3
votes
2answers
2k views

Simple dice console game in C#

I wrote a little console game that is supposed to take some dice and some players and determine the winner of the game. I wrote it for the sole purpose of figuring out why i'm doing the things i'm ...
-1
votes
3answers
769 views

Distance too close

Are two points too close? Trying to do the math as efficiently as possible. deltaX + deltaY is going to be > than the actual distance You might use this in game play - are players in range? ...
3
votes
5answers
2k views

Absolute Values and Fractions

$$ \frac{|x|-|y|}{1+|xy|} $$ How can I reduce the amount of code without losing quality? What are your tips? Your comments on the structure, logic, in general, everything. How to make the type of ...
4
votes
2answers
1k views

Classifying a person by name, gender, and age using Chain of Responsibility pattern

I am very new to design pattern. Recently, I learned about the Chain of Responsibility pattern, so I tried to practice it. These nested conditionals are what I'm trying to replace with polymorphism ...
5
votes
3answers
469 views

The Atbash Cipher

I am doing some exercises in C# and I have just finished writing my own implementation of the atbash cipher, here is the code: ...
4
votes
1answer
335 views

Flexible TCP socket framework

I'm working on a flexible socket framework and trying to polish it so it's actually something usable in further development. Would really appreciate any critique, also I’m really interested whether I'...
1
vote
0answers
34 views

Script to append a new method to a XAML code-behind file

My company is converting a VB.NET project to a C# application and I was tasked with writing a script to automate part of the process. In particular, given information about a control name and event in ...
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 ...
1
vote
0answers
321 views

Sauna experiment

This is my program for a sauna. It is a Swedish sauna meant to only understand Celsius, but the user can only understand Fahrenheit, so when the user inputs Fahrenheit it is converted to celcius. ...
2
votes
0answers
512 views

Hashing a SecureString in C#

In .NET, the SecureString type exists to prevent leaking secrets in memory. I want to create a hash from the contents of a SecureString, without putting the contents in memory in a place where I can't ...
12
votes
3answers
461 views

Key Order Agnostic, 2D Dictionary

Note: I am using Unity3D game engine, which uses .Net 2.0 (.Net 2.0.50727.1433 to be precise) to compile code, so I don't have access to newest features of C# 6, or even C# 5. Please keep this in ...
4
votes
2answers
62 views

Implementation of undoable arrange (SendToBack, SendBackward, …) operations

I am developing a WPF designer where visual elements (rectangles, ellipses, ...) can be inserted, moved, resized and so on. Similar to a simple PowerPoint control. All the actions should be undo-able,...
2
votes
1answer
141 views

Extension method replacing elements from an IEnumerable<T> collection follow up

I got some amazing feedback on my previous question and I decided to extend this method and add it to my own library where every now and than I will add some methods I feel can be useful in the future....
11
votes
3answers
8k views

Extension method replacing elements from an IEnumerable<T> collection

Today I needed a method to replace all 'x' values in a said collection. Since there is no such method by default in .NET I wrote my own: ...
-2
votes
3answers
161 views

Find target sum of 3 from and array

Input is a sorted array and a target sum. Find all sets of 3 unique elements that sum to a target. Looking for lowest order (big O). A, B, C are the indexes on the sorted array. A < B < C ...
2
votes
1answer
40 views

Loading and parsing WinForms menus using LINQ

I'm refactoring a WinForms utility program for building and testing regular expressions. The program has a menu item which lists the RegexOptions enumeration, ...
2
votes
3answers
210 views

Laundry - sort socks

This is very artificial problem Each sock has exactly 1 match. Can only take one random sock out of the Laundry basket. Can only compare to the last random sock. If it matches you put the match ...