Tagged Questions
C# is a multi-paradigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform.
0
votes
0answers
11 views
UDP Server Design and Performance
What I'm doing
I am writing a server to work as my games backend. The server is being written in C# using UDP as the protocol, while the game is in C++. The biggest thing I've been focusing on was ...
8
votes
1answer
196 views
RPG Currency System
I just spent the last few days constructing the currency system for my game, and was wondering if you guys had any suggestions on how—if at all—I could improve it. Before I show the code, let me ...
3
votes
1answer
42 views
Detect and Fix Switching over an Enum Without Handling all Members
VSDiagnostic's latest refactoring and code fix detects when a switch does not contain case statements for each of the ...
1
vote
0answers
11 views
WPF Track child collection validation errors
I have a need to get notified about validation errors that occur in a child collection of my ViewModel. For validation I use the ...
2
votes
1answer
31 views
c# Multi process, multi thread read write on a single file
I've got a job to create a library that would be able to support multi threaded and multi process read and write to a single file. On that single file we would store c# models in an array in json ...
1
vote
0answers
33 views
Priority message sending
We have created a message queue system using priority messages. The idea behind this code is as follows:
We have a list of clients.
All clients know if (and what kind of priority) messages they have ...
1
vote
1answer
50 views
Repository Pattern universal application
When I started learning Repository Pattern with Unity few days ago I was under impression that the main benefit of this pattern is the separation of data layer from the business layer.
In other ...
2
votes
0answers
23 views
Controlling a drone in Unity3D
I'm currently building a game called "Drones! Attack!", and I needed a drone controller that the player can use. It's currently very simple and only supports a small amount of actions, such as:
...
0
votes
0answers
27 views
Distinct List of attribute values from XML, using a pre-defined set of attribute names
I have an XML stream that looks like the following (attribute and node quantity , and node depth reduced for demonstration purposes.)
...
3
votes
1answer
61 views
Returning an IEnumerable using Linq-to-SQL which is then bound to a GridView
This function works, but it's really really slow and the generated SQL is gargantuan and horrible to look at. It's also very expensive to run when it shouldn't be.
...
1
vote
1answer
26 views
Multiple emails and attachments, reusing memory stream
I am generating a pdf form based on user input from an MVC website form. The pdf is genrated using the Foxit .NET SDK, then attached to three separate emails, generated using Postal. It has been ...
3
votes
0answers
35 views
Event delays for a Monogame project
I am making a GUI for my C# Monogame project. So since this was the first time I ever made a GUI that is not winforms-based I took a wrong approach in making it and thus I decided to change it ...
2
votes
1answer
71 views
Lazy prime number generator
There are multiple Project Euler problems (e.g. 7, 10) that deal with prime numbers. I decided make a reusable solution that could be used for most of them.
I wrote a method to generate an infinite* ...
0
votes
0answers
42 views
Pass several classes as one parameter with Poker user controls
I have two classes that hold some info about the user. One holds the data, the other one holds the controls info. Now I need to pass both of them as a parameters to a method. However they are ...
0
votes
2answers
72 views
Asynchronous lookup over HTTP and checking the status
For some reason declaring ApiResult before checking if the answer is in a correct status doesn't look good. I wonder if there is any better way to check the status ...
1
vote
0answers
45 views
Finding a Cartesian product of multiple lists
I came up with an extension method to find a Cartesian product of multiple IEnumerable sets. I was able to achieve lazy enumeration via ...
1
vote
2answers
58 views
Player classes for a playing card game
I have a simple base class and two derived classes. However, when I'm creating new instances of that class, the line where I instantiate the variables is getting way too long.
I have it on two lines:
...
0
votes
0answers
20 views
Show products in dropdown from parent to chid
My goal is a list selector like this:
To do this I wrote these methods:
First:
...
3
votes
2answers
96 views
Beginning C# dice game
I've been learning C# for about a month and have a finished game. I would like some constructive feedback on my progress so far.
...
6
votes
2answers
150 views
Saving and Loading data with SQLite
I'm in the process of learning SQLite in C# and I've come up with some generic methods for finding and updating data. I would appreciate any pointers with the design of my methods and/or my SQL ...
1
vote
0answers
42 views
Right usage of ViewModels in MVC
I'm new to MVC and i'm having some difficulty on understanding the proper usage of ViewModels and Controllers.
I have this ...
2
votes
7answers
576 views
Producing triangles of asterisks based on height
I have created a simple terminal program: it allows the user to enter a height and it will produce triangles of asterisks (*'s) based on the height.
I have just started learning C# as practice for my ...
3
votes
3answers
179 views
Extracting Excel data out of an existing Excel file
I've made a method to extract Excel data out of an existing Excel file. It contains 3 tabs where info should be extracted from. The data should be stored to use local so it's always fast available. It ...
4
votes
2answers
173 views
C# Winform Amazon Application
This is my first program I've written ever. Don't hold back on me. Any help and feedback is appreciated. This code wont work because it requires some keys, but I censored them out, but it does ...
3
votes
1answer
46 views
Application Settings Helper
I'm developing an app which stores some different user settings in app.config such as connection strings, paths for saving reports, default printer e.t.c
For retrieving them I made a static class ...
3
votes
2answers
64 views
Custom key class for .NET 3.5 framework
I use .NET 3.5 framework, so no tuples. I have many use cases where I have to create a custom key for a dictionary. How can I make this better?
...
6
votes
1answer
225 views
C# Bitwise Operators
I have a simple program that calculates and outputs the results of all the bit operators. I'm planning to send it to my friend and to explain some stuff about them to him. Before I do that, I want to ...
0
votes
1answer
37 views
Using EF 6.1 for updating objects and their children
I have an application that allows a user to create a poll that includes questions and answer choices as part of the poll. The hierarchy is a poll has one or more questions, a question has one or more ...
4
votes
3answers
2k views
Comparing Equals() method from MSDN
I've implemented the Equals() support for my class as follows:
...
0
votes
2answers
79 views
Morse Code Translator in C#
I'm writing a Morse code translator for homework in C#. I understand that this code may look horrible, so how could I improve it in terms of efficiency and readability?
The program takes an input ...
1
vote
0answers
26 views
Excel-to-JSON parser 2
After first code review I have fixed the found issues. Could you please review my new refactored application?
Main class (entry point)
...
1
vote
2answers
128 views
Divide list into batches
Three questions: is there a more performant way, is there a more suscinct, strike that, a way of expressing this where if you read just the body it is immediately apperent what the alorithm does, and ...
1
vote
1answer
74 views
Throwing exception in the singleton pattern in C#
I'm implementing an HTTP client shell that's going to be used for the lifetime of my application in C#. It needs to be initialized before the instance can be accessed. It looks something like this:
...
1
vote
1answer
41 views
INSERTing a student info record based on form inputs
I want to improve my coding skills. How do I write this code with concatenation
...
0
votes
0answers
6 views
A property that can represent both a fixed date and a day range: How to properly model that? [migrated]
I work in a system that can represent a "shipping estimate" in two ways:
A specific date: The item is guaranteed to ship at that date
A day interval: The item will be shipped "X to Y" days from ...
6
votes
2answers
170 views
+50
WinForms Poker (complete project)
I have quite huge question/favor to ask but I hope I can get some useful answers. This is my first complete project, I'm still learning C#, my first programming language.
I'm afraid that there will ...
1
vote
1answer
62 views
LINQ query for a user's submitted time-off requests
What is a better way to create this select statement? I tried to just select 'u' and 'us', but the object properties were not accessible when I did this.
...
-1
votes
0answers
22 views
C# Poker Project WinForms [closed]
guys I have quite huge question/favor to ask but I hope I can get some useful answers. First of all this is my first complete project I'm just 16 years old and still learning a lot of stuff about C# ...
0
votes
0answers
13 views
Guidance on the use of Ninject and Constructor injection [closed]
Thanks to Mat's Mug's answer on this question Guidence on the use of Ninject as IoC Container in a WinForms MVC Application I have made some progress with my architecture, however, I have further ...
0
votes
0answers
43 views
Use StringDictionary instead of Dictionary<string, string>? [closed]
In my current MVC project, I have the following code, which uses a Dictionary<string, string>
Model:
...
1
vote
0answers
33 views
Safe async API code
I'm pretty new to async/await and I want to ensure that the code I've written is going to be safe and not cause any deadlocks.
The RestClient in the code will be ...
0
votes
1answer
40 views
Excel-to-JSON parser
I just wanted to build a simple converter from an XLS Excel file to JSON. I have predefined JSON format. All fields except of two - are just simple mapping from Excel to JSON. The two fields have a ...
3
votes
3answers
340 views
Optimizing timeline generation
I have a bunch of processes that are being executed on different virtual machines. All of those processes have a StartDate, ...
1
vote
1answer
43 views
2
votes
2answers
41 views
Instantiating different kinds of error records for a database operation
I've written code to be called from Powershell like so:
Rename-DatabaseUser -Name 'someuser' -NewName 'somenewuser'
I'm wondering if there's another way I can ...
6
votes
2answers
77 views
Opinion on performance increase of a robot
Background
A prototype of a firefighting robot has been done recently based on an Arduino microcontroller. It has two servos, one laser LED and 2WD motors. The desktop application is done in C# to ...
-2
votes
0answers
29 views
c# How to fetch data from database and display it on textbox AUTOMATICALLY [closed]
So the code below works but I use a button, and I have to press the button everytime to fetch information. Does anyone have any advice on what should I do to automatically fetch information from ...
6
votes
2answers
80 views
Recursive directory copy program
A little while ago, I had to write a little C# application to recover my HDD data (full context on this question)
To answer my problem I developed a console application which job was to recursively ...
3
votes
1answer
86 views
Use of Ninject as an IoC container in a WinForms MVC application
I am a relatively experienced WPF developer who has had good exposure to MVVM. I have been developing legacy WinForms applications for a while and have recently been asked to fully re-write a large ...
-2
votes
0answers
37 views
Static classes / methods are getting bigger, is this a code smell? [closed]
Recently I've observed that static classes/methods have been getting updated continuously to support more features (agree, already breaking Open-closed principle).
Initially when it was started the ...