Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [c#]

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

1
vote
0answers
29 views

Simple c sharp calculator

I'm doing simple calc for my school. Code looks okay to me, not sure if there is something to improve, but probably there is always something to improve. Any ideas how to make it look and work better? ...
4
votes
0answers
13 views

Prototype GameManager for game written in Unity

I am self taught, so I'm consistently seeking ways to code better, and more efficiently. If anyone has the time, please advise me on what can be done better with explanations as to why the old method ...
0
votes
0answers
22 views

Bartender Project - exporting printer code templates - Follow-up-2

Here is my second revision of my code. The other revision (and the base project) may be found here: Original: BarTender project - exporting printer code templates 1st Revision: BarTender project - ...
1
vote
0answers
49 views

Controller method to add a folder to a tree

I am using the jstree to get a tree structure in my MVC application. I am actually on showing javascript errors, when something is wrong. In this case, returning an alert to Javascript. Furthermore I ...
2
votes
0answers
42 views

Data Transfer Task

The task: You will be given several lines of messages containing data. You have to check for the validity of the lines. A valid line should be in the format: ...
-2
votes
0answers
17 views

C# Selenium - How to retain Parent URL Info in Recursion [on hold]

I have written a test automation program the recurses through all links under a page element. However, for some reason it is not preserving the parent URL info where a particular link's web response ...
-2
votes
0answers
28 views

Parallel Foreach loop [on hold]

GetValuesFromDB will fetch values from the DB and return a new object which will have SubStatus. ProcessCounter is a class that defines SafeCounter for Processed, Passed, Failed and Skipped. The ...
2
votes
0answers
49 views

Repeating a task that may fail (in parallel)

Almost like this question here, I'm playing with some methods that may fail, but in my case, the method failing is not a exceptional case; it just means I need to try running it again. The method I'm ...
2
votes
1answer
37 views

Reflection optimization for export CSV on large scale

So, I'm building export/import CSV helper. I have some performance issues in the code below. it takes me to parse CSV of 25,000 rows at 7 seconds. If someone can help, it will be awesome! ...
1
vote
1answer
31 views

Database as a config and class structure to call it

I have question regarding best practices. I've decided instead having config inside either app.config or xml file to have my config file inside SQLite file database. This config will contain basic ...
8
votes
2answers
466 views

Calculate subtotals and totals from a form with many decimal values

I've got 17 currency fields on a form and need to do some calculations with their values. I wrote this method some time ago and have come back to try and refactor it to make it more efficient and/or ...
-1
votes
0answers
28 views

RabbitMQ class in C# [on hold]

I have this class: ...
0
votes
0answers
38 views

Pull records of people from database [on hold]

So as the title suggests, I am really just looking for feedback/alternatives. This is a practice more than anything. So essentially my goal was at the very top of the application, I have (even though ...
2
votes
0answers
18 views

VSTO add-in for Excel to solve systems of linear equations

This code is part of a VSTO add-in for Excel. As the title states it solves systems of linear equations by allowing the user to select the appropriate ranges. The code works and covers most issues I ...
-1
votes
0answers
46 views

BarTender project - exporting printer code templates - Follow-up

This is a follow up to a previous question previous question: BarTender project - exporting printer code templates Second Revision: Bartender Project - exporting printer code templates - Follow-up-2 ...
-4
votes
0answers
29 views

Get all points within a triangle is causing an overflow [on hold]

Well I'm lacking GraphicsPath in Unity (to fills polygon, draw them with and outline and utilities with shapes in general), so I'm doing my own implementation of it. Well, we could debate also which ...
1
vote
2answers
91 views

BarTender project - exporting printer code templates

Follow-up Code: BarTender project - exporting printer code templates - Follow-up Second Revision: Bartender Project - exporting printer code templates - Follow-up-2 as stated in the question I've ...
-1
votes
0answers
38 views

Can I simply my lengthy shorthand string comparison? [on hold]

In one of my applications I receive a datastruct built like this: parent: { x, y, z, child[]: { x, y } } I select the parent object, and then loop through ...
4
votes
1answer
98 views

Collections management with many derived elements

I've been told few days ago that using is is a code smell and anti-pattern. I used it in an game to filter some elements of a collection (the inventory of the ...
1
vote
1answer
40 views

Set / verify password using REST API

I have limited experience with both making REST APIs and implementing security features, so I figured it'd be worth running this code through some other people's eyes before making it live. My main ...
-1
votes
0answers
36 views

C# ClientWebSocket implementation [on hold]

I'm working on implementing websockets in my current project in C#. Could anyone please give me some pointers/suggestions for what could be improved? Specifically, I'm most unsure about how to ...
-1
votes
0answers
28 views

Avoid SRP violation in Console application [on hold]

I'm developing a simple Console application. Program.cs initialize dependency injection, set file names, accept inputs and print the result. I got a note that my Program.cs violates the SRP principle ...
0
votes
3answers
74 views

App that sets configuration data

I've been writing my code like this for a really long time now, I am wondering if there is a more efficient way to do this. This is especially after a senior developer said my code was very amateurish....
-1
votes
0answers
11 views

Get pixel data from image UWP [closed]

I'm writing a simple tool, the user can select an image and it should list all the colors found in the picture. Now, I'm facing 2 main issues, one is that it's slow because I'm looping through all ...
1
vote
1answer
72 views

Parsing displayed month/year for calendar

I have a 6 x 7 grid for a calendar = 42 DateTimes. I'm trying to display the displayed month/year at the top of the calendar. If there are 3 months displayed, I ...
9
votes
2answers
143 views

Project Euler #119 : Digit power sum

From problem #119 of the Project Euler : The number 512 is interesting because it is equal to the sum of its digits raised to some power: 5 + 1 + 2 = 8, and 83 = 512. Another example of a number ...
-5
votes
0answers
17 views

View XML file elements in Label with next button and previous button [closed]

I have an XML file with data I want to display all the elements in their own Label with a button to display the next element and a button to display the previous element for example : xml file: ...
1
vote
1answer
47 views

Creating method to use one foreach instead multiple [closed]

I'm working with C#, and I have working code where I repeated same code every line, and that's because I'm creating list, conversions, extracting data, etc. I have multiple ...
-1
votes
0answers
28 views

Trying to Complete a homework project and not sure what the instructions are asking for [closed]

Assignment instructions image Main.cs the body of the program as i have written it so far. ...
3
votes
1answer
52 views

Generating report columns from SQL query

I've written this class to create RapportColumn objects for each column that is written in the query. And I would like to get your feedback. The query that is ...
-2
votes
0answers
30 views

get data in database and generate files in docx format [closed]

My software generate legal documents for lawyers. After completing the information via forms The user can create document templates with docx format and can use macros like this: ...
-4
votes
0answers
20 views

How to set string image name as image [closed]

I need to set a random image from a string array images names. How can I do that? I've already generated a random image name but can't set it as image This is the code: ...
2
votes
1answer
265 views

Executing query until there is nothing more left

I often query a database to get a batch of items to procees. I do this as long as the query returns some items. I use this pattern quite a lot so I thought I create a small helper so that I don't have ...
-4
votes
0answers
23 views

Parent And Child Number each 2 id C# [closed]

how to get when each parent id 2 and each child 2 id how to count all id and how it show on label C#
2
votes
2answers
122 views

C# classes for adding form components dynamically

I'm currently reading on how to implement design patterns. I'm trying to implement the design patterns but need help on whether my understanding is correct. I have a windows form in C# project that ...
4
votes
2answers
307 views

Reading SQL query from a resource, with error logging

I've created a utility class that expects a logger to be passed at a method level, since I prefer legitimate errors to be written out for troubleshooting later on. Another developer hates passing the ...
6
votes
4answers
139 views

Selecting random elements from a `IList` with no repetitions

Description This is a utility algorithm that selects a number of elements from a source list without repeating elements. Background My use case is creating a random path for a NPC that has to ...
3
votes
1answer
73 views

C# screen recorder [closed]

After a while of working on it, I've finally got my screen recorder to work in C#. I'm looking for suggestions to improve the video quality as well as clean up the code a bit. Specifically I want to ...
6
votes
0answers
48 views

Visual Studio exception visualizer for lengthy exception messages

I use Autofac a lot and for everything and when you make a mistake and forget to register a dependency etc. it'll tell you exaclty what's wrong. Although its ...
1
vote
0answers
34 views

ServiceLocator<T> with internal set [closed]

I was looking for a statically typed way of implementing a service locator and started by reading this series of posts. I then had an illumination. How about a static templated class with a single ...
4
votes
2answers
98 views
2
votes
3answers
175 views

Leetcode #91 - Number of ways to decode a string

I'm working on problem 91 on Leetcode.com called Decode Ways and I've successfully managed to get a working recursive solution but it results in Time Limited ...
5
votes
1answer
97 views

Requesting 400 links with multithreading and ThreadPool

I am working on multi-threading application to learn multithreading better. My application has a queue with 400 unique links, 4 threads and each thread is pulling link from the queue and sending a Get ...
2
votes
1answer
52 views

Squeezing decorators into functional extensions

When you try to use several decorators it can get ugly pretty quickly and you'll end up with: ...
0
votes
0answers
18 views

Apply vertex color in a propagating-wave type visual effect

I created a little tool to help apply vertex color information in a propagating-wave type visual effect, which is animated via a shader. The initial setup uses a UI window to select a closed ring of ...
3
votes
1answer
56 views

Simple fluent library to validate text content

Before I can perform a more or less complex mappings, treatments in business objects and saving results in databases, I often need to validate contents from flat text files or excel files All the ...
4
votes
0answers
69 views

Chaining JSON transformations with visitors

I have currently two use-cases that require JSON transformations before it can be deserialized. The first use-case requires changing the custom short type property name from ...
6
votes
2answers
117 views

Salary-calculating classes, supporting several types of employees

I develop this mini project as an exercise. It is a simplified employee salary calculator. Requirements: Employees are characterized by name, employment date, employee group and base salary. There ...
0
votes
1answer
54 views

Merging two lists into one by dates [closed]

I have two lists of Slots ...
0
votes
0answers
30 views

LDAP Authentication service. Passing UPN with password

We have a bunch of projects where users login with UPN. Multiple UPN-suffixes are available: bruce.wayne@work.com bruce.wayne@batcave.com We want to allow users ...