Tagged Questions

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

-2
votes
0answers
32 views

C# in Visual Studio [on hold]

C# Program Determining if a number is either a multiple of ten or within a particular set of ranges I have a few loops that I need in my program. I can also write out the c# code but I'm not entirely ...
4
votes
1answer
43 views

Finding Magic Comments to Create a Custom Task List

I've been working on a COM Add-in for the VBA IDE with a friend. The idea is to search the active VBA Project for "magic" comments and create a task list much like any sane IDE would have. This is ...
2
votes
1answer
20 views

Improvement on a triggered movement script

I am trying to more or less perfect a movement script that activates when "triggered" by another object. Below I have the code for both the triggering object as well as the object being triggered. I ...
5
votes
1answer
37 views

Get all points on a uniform discrete grid inside a circle's radius

I have a 2-dimensional grid defined by a known point gridCenter and distance between points gridStep and need to find all points ...
-2
votes
0answers
23 views

This one time, I called a constructor and got a null reference exception [on hold]

This is the whole pasted version of a particular page load I have on some page somewhere. Extra detail: ServerData is a class with an overloaded [] which brings back a list of interfaces based on ...
1
vote
1answer
35 views

Enumerate directories to a given search depth

Since I had been in the need of finding directories from a startpath with different search depth levels, I created this little helper class. This class is using objects of the ...
0
votes
0answers
47 views

Why is loading images taking so long?

When Page_Load is executed I assign the ImageUrl which is a IHTTPHandler: ...
3
votes
0answers
36 views

Game stats storage / display

I have a simple game where you try to go as high up with rockets as possible. I currently store 2 statistics about your playthrough: Current altitude Highest altitude These statistics are stored ...
0
votes
3answers
66 views

Using a `for` loop to fill 20 picturebox number 'i' with image

I implemented as follows and it works (I got the solution here: Using a 'for' loop in C# to fill picturebox number 'i' with an image), but I really wonder if I can do that without having to define an ...
2
votes
1answer
44 views

Prefer simplicity over testability? [on hold]

Currently I try to create some unit tests for a project, which provides access to some webservice methods. It's interface is rather simple. I have a class "WebService" which offers methods like ...
2
votes
1answer
60 views

Is this the correct usage of ConcurrentDictionary<TKey, TValue>?

I need to make a simple class that tracks how many clients are listening to a specific item, will be referred to as building hence forth. I will have a timer running that will check which buildings ...
2
votes
1answer
61 views

Is there a better design pattern for a SDK?

At work I decided it would be better to reverse engineer a SDK for one of our pieces of hardware. Because it is work related I can't share the exact code.. but I can give enough of a gist of the code ...
2
votes
1answer
58 views

Null checks in view

It's really a nitty-gritty issue for me, and I have been here many times before. How could this be improved? I have a basic viewmodel for a view: ...
1
vote
0answers
26 views

Asynchronous task and close sql connection

The following code compiles correctly: ...
4
votes
2answers
82 views

Check if any of class properties is not null/empty/was assigned

I have a class that I use to display on a web page fieldset. However, all of the properties of this class are optionally filled in by the user, which means all of them could be null/default. In this ...
5
votes
2answers
95 views

Time Sensitive ConcurrentDictionary

In our application, we have many function calls that we want to cache the results of. However, the result of these functions depends on database calls, so we want this cache to refresh every so often ...
2
votes
2answers
55 views

Transliterating Tatar To Cyrillic

Input : <h2>{translate} Dear Atteck {/translate} <br/></h2>{translate}Please complete registration</h5> {/translate} Output : ...
0
votes
1answer
42 views

Use parent class to declare a child object or how compiler allocates memory

I'm working with C# and .NET Framework 4.0 and Windows Forms. On my project I have three custom objects that inherits from MyControl class (...
1
vote
2answers
59 views

ComplexProperties with Reflections

I have used reflection for divide the complex property. For example, if I bind A.B[0], CustomerName means CustomerName is returned. Can anyone help to reduce the ...
0
votes
0answers
36 views

Console Application Customizer - GetBootstrap v2.0

GetBootstrap-2.0 update from GetBootstrap-1.0.0.2 I just update my console application customizer and add some new features like disable minimize, maximize and close button, new color and simple ...
3
votes
2answers
128 views

Sorting by patients' name or birth

Is there a way to write this simpler? ...
3
votes
2answers
174 views

Get missing sequential numbers from array

I have an array like Original = {1, 2, 3, 6, 7, 8, 9, 10, 12}. After removing some elements like Delete = {6, 7} from it, I want ...
5
votes
2answers
102 views

C# program that uses events

I am trying to learn C#. Please tell me if the following code respects coding standards and naming conventions because I want to write beautiful code. The purpose of this program was to help me ...
-4
votes
0answers
18 views

how to Search text in PDF,excel and word documents if content available in file show file link and bind in grid(C# sample) [closed]

I have a folder with a lot of PDF,excel and word files. I would like to develop an ASP.net application that enables the user to search by text in available inside pdf,excel and word and bind file in ...
-1
votes
2answers
60 views

Sorting array with respect to two properties

I'm sorting with respect to Width and Length. However, Width has the significance ...
2
votes
2answers
149 views

Returning latest database ID

I want my method to use a finally block so I can be ure that my EF entity is disposed after usage, even if an exception is thrown, but I would also like to not ...
4
votes
1answer
39 views

Stop Watch Application 2.1

After the tips from my previous review. I have come up with these changes: Separation of Concerns Use Delegates I'm asking you guys if this looks good. Other then separate out the ...
7
votes
2answers
94 views

Applying a 'mean filter'

I am just trying to apply a "mean filter" with C#. The working code below gets window size (3,5,7,9,...) from textBoxWinSize and applies the mean filter. I am new ...
3
votes
1answer
45 views

Easier way to handle a Console Theme System

I'm just curious is there an easier way to handle console colors rather than just doing something like the code below. The problem is the code bloat I'm experiencing when writing a theming system for ...
5
votes
1answer
54 views

Dictionary Key look up with variable length inputs

I am decoding GS1 barcodes and need to match up application identifiers with relevant data about them. ...
-1
votes
0answers
15 views

Example: Interfaces for adding data to a collection (readability, extensibility) [closed]

I'm looking for some good practice advises regarding designing class interfaces where multiple methods should be provided to do a single task. As an example: Adding data to a collection. Requirements ...
4
votes
3answers
101 views

Click handlers for two to ten buttons

I have click event handlers for two buttons. The code is working well, but I want to apply the DRY principle. How should I rewrite the following code in the button_click event handler so that I don't ...
-1
votes
0answers
14 views

method to receive wholesale cost and markup % as arguments and return retail price c# [closed]

I typed out this code for homework and it works. However, the method part is incorrect. The method should receive 2 values (wholesale price and markup percentage) from the form as arguments and return ...
0
votes
0answers
31 views

Correct usage of Repository Factory Pattern? [closed]

My repository pattern is setup like this: ...
0
votes
0answers
19 views

Handling WinAPI return values and errors without code being verbose [closed]

I'm trying to come up with a way to streamline a bunch of WinAPI calls that return true or false without having a bunch of ...
1
vote
2answers
38 views

Double Inclusive Range step by step

I've written a method to obtain an IEnumerable from a start point, end point and step. Similar to Enumerable.Range() but for doubles and not fixed step. ...
1
vote
1answer
32 views

Authentication with JWT

Please review my code for 'JWT' authentication. Are there any security issues? Where should I store the secret's key, DB or InMemory? What's a good 'JWT' Lifetime? Should I send the 'JWT' in Header ...
1
vote
2answers
71 views

Normal distribution array function [closed]

I have a function that produce an array with values that are Gaussian(normal) distribute. If you plot the values on a graph, it would look something like this: Is there any way to improve on the ...
2
votes
0answers
42 views

Generic repository pattern

Please have a through look my custom implementation of generic repository pattern and suggest anything I may be lacking. I am using a generic interface with 6 methods I'll be using a repository ...
0
votes
1answer
42 views

Is a single instance of reusable HttpClient a bad idea?

I've got a method shown below and I realize that an instance of HttpClass is going to be created for each call to it. While working seemingly OK, I consider moving it out and place it as a private ...
2
votes
1answer
64 views

CSV writer implementation refactored

Based on my initial implementation found here and the suggested improvements in answers and comments, I've refactored the code. The main changes are: Removed redundant buffering. Simplified ...
3
votes
3answers
485 views

Code optimzation by constant if-structure iteration removal

Below you will find the specific code that I am attempting to optimize. I have a method previous to called getCount() which, based on similar parameters as below, ...
6
votes
1answer
150 views

CSV writer implementation

I've recently been assigned to write up a CSV writer with "as much flexibility" as possible concerning pretty much all (output stream, string fields with potential new line characters, separator ...
3
votes
1answer
67 views

Compressing a stream asynchronously, and returning a byte[]

Assuming I have to leave the contract intact (take byte[] and return byte[]), what's the correct way to structure this ...
6
votes
0answers
57 views

Mutual Exclusion with Mutexes

After I wrote this question: Producer/Consumer programs, I realized that I had forgotten to write a version using mutexes. I have now written a Producer/Consumer problem solver using mutexes using ...
17
votes
2answers
455 views

Where equations are born and mutants are buried

I've read up on genetic programming yesterday so I figured I'd try to implement something myself. I would like the main focus to be on whether or not I've implemented the idea behind it correctly. ...
2
votes
0answers
39 views

Dapper helper service

I've written a very light wrapper around dapper to help with unit testing and streamlining the dapper commands I need. Execute() is a method created to remove the ...
2
votes
2answers
245 views

c# best way to declare a class-level value in base class and set it at derived classes [closed]

I have a root class and I'd like to add an indicator to it (property, static field, readonly field, virtual method or something like that), that should give me the same string value for every instance ...
3
votes
2answers
268 views

Getting valid URL from user input

I have a dialog which populates my ConnectionStringData object with the URL of the service that I'm trying to connect to. I then consume that URL with the following ...
0
votes
2answers
79 views

Connecting to a MySQL database with C#

Can anyone help me with checking this code? It is for connecting to a database. The method getFromDatabase is to take values from the database and put it to a ...