C# is a multi-paradigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform.

learn more… | top users | synonyms

0
votes
0answers
8 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.) ...
0
votes
0answers
10 views

Returns an IEnumerable using Linq-to-SQL which is then bound to a GridView. Horrible performance

So, this is my function. It works, but its 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
14 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 ...
2
votes
0answers
16 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
47 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
36 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
1answer
32 views

Declare variable to hold the result before 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 and return the result: ...
1
vote
0answers
32 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
54 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
19 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: ...
2
votes
2answers
88 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
145 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 ...
0
votes
0answers
24 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
562 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
172 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
169 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
42 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
62 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
220 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
35 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
77 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
25 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
126 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
69 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
159 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
58 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
21 views

C# Poker Project WinForms [on hold]

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 [on hold]

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
42 views

Use StringDictionary instead of Dictionary<string, string>? [on hold]

In my current MVC project, I have the following code, which uses a Dictionary<string, string> Model: ...
1
vote
0answers
32 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
38 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
339 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

Method for get base URI

How can I improve the following code? ...
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
76 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
77 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
83 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
35 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 ...
2
votes
0answers
40 views

Uploading .dll files to a local computer

I have created a simple application that has grown a little bit. Though most likely it won't grow anymore, I have looked back and I realized that it has become a little monster in terms of how many ...
-2
votes
0answers
22 views
2
votes
1answer
35 views

Processor that would process an Object (say a message you received)

Sorry for being a little abstract but I have attempted to concoct something simple but it seems to spiral out of control. So I was thinking maybe I am taking the wrong approach. Here's what I am ...
0
votes
1answer
46 views

Create Xml to string serializer

I don't want to serialize everything. I created a custom attribute DoNotSerializeAttribute. If some property in info contain ...
7
votes
1answer
87 views

Milking a COM type library: “fun” with COM reflection

Once upon a time, there was a duck that wanted to know where and how user code was calling into the VBA standard library and Excel object model. To match the rest of its API, the poor little duck had ...
1
vote
2answers
95 views

Strategy pattern using an abstract class and an interface

I have implemented some sort of the strategy pattern using an abstract class and an interface: ...
1
vote
2answers
107 views

Derived methods with Poker classes

I have an interface with two functions. This interface is being inherited by an abstract class which implements just one of those functions. The other one is left to be implemented by the derived ...
3
votes
1answer
65 views

Age Calculations (First Draft)

I found another user asking for an application to be written, it sounded simple enough and a good way to "work out" my C# "muscles" and try to get them into a better "shape". I really liked the idea ...