C# is a multi-paradigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform.
1
vote
0answers
7 views
Creating a Generic Template Interface/Class and injecting into another object
I would like to create a generic template class for my document processor. Assuming the template has a source file path and a "content", here's what I came up with:
Template
...
2
votes
0answers
16 views
Code snippet for a method dealing with IDs from multiple threads
I have multiple threads calling a method, passing in an ID and value.
I have two constraints I need to place on this method:
Only one of the same ID can be processed at a time. Additional threads ...
-4
votes
0answers
15 views
6
votes
4answers
296 views
Using LINQ or Lambda instead of nested and multiple foreach statements
I want to use a better syntax than nested foreach statements to overwrite the initial list with items from the second list.
In the code below:
I want to ...
-1
votes
1answer
35 views
DDD and Dependency Injection a smell or common [on hold]
I am working on a little something to build up my understanding of DDD. Those of you who are familiar with the game Fantasy Premier League will perhaps understand my dilemma or even maybe inform me I ...
-3
votes
0answers
13 views
Delete Button Not Working [on hold]
I have a delete button that will update the is_deleted value from 'n' to 'y' based on the selected checkboxes in the gridview. The checkboxes are dynamically made using template field and the gridview ...
-2
votes
0answers
16 views
In following scenarios what's the best practices in C#? [on hold]
What are the best practices in following scenarios
Calling one method
Approach 1:
MyClass myObj = new MyClass();
var data = myObj.CallMyMethod();
Approach ...
4
votes
2answers
37 views
3
votes
1answer
72 views
Correct usage for singleton and reusability?
I've made the following DataSetReader, DS Attribute, and DataSetManager.
My main concerns ...
4
votes
1answer
56 views
Get result from UI thread to non-UI thread when using await Task.Run
I have application where I use Task to run a operation. During the operation there can be a problem what will need some user interaction (continue or not). I need to bubble up a ...
5
votes
2answers
62 views
-1
votes
0answers
19 views
Separate error handling logic with Unity [on hold]
I have WepApiService for requests to web service.
IWebApiService
...
10
votes
1answer
94 views
The thing that makes API requests
I'm creating a thing that does things. Part of the things the thing does is querying an API for information about movies and TV shows. The API allows me to query for changes to their data so I will ...
4
votes
1answer
54 views
Forced Async operation in a (event like) method
I have a piece of code that I am not feeling comfortable.
I don't want to block the UI
Read operation works synchronously (reading may broke 50 ms rule)
Save operation supports async (returns ...
-4
votes
0answers
20 views
How to draw a simple hollow asterisk rectangle of rows & column provided by the console in C#? [on hold]
Could someone advise me on a simple way to implement Hollow Rectangles in C#? I have been able to make a rectangle and the hollow rectangle programs I've looked at either contained or arrays or were ...
0
votes
0answers
9 views
Can't access elements of the array after for loop [on hold]
I tried to display the elements of a char array after the for loop wherein I assigned the value but when I display it after the loop, there were no output as if the array is empty. Can you please help ...
3
votes
1answer
43 views
Measure Method executing time - 2nd Attempt
Long time ago I've written a method that would allow me to measure the amount of time a method takes to run. I've decided to tweak this method and make use of TPL since measuring a method may take ...
3
votes
1answer
33 views
Reducing repetition of sequence-like properties
I have a class that is a wrapper for memory positions of a hardware device.
I need to data-bind each of this positions, so I created a class with hardcoded properties, one for each position, so that ...
3
votes
1answer
70 views
Memory leak using UserControls
I seem to have a memory leak on this method but can't figure it out. This method is called every 10sec by a timer which acts like a refresh.
...
-2
votes
0answers
32 views
Dependency Injection for Db without using repository or with repository [on hold]
I need to test my MVC existing project in VS 2013 but problem is it throws an exception when I create an object of TestingController due to the ...
0
votes
0answers
22 views
4
votes
1answer
56 views
Overriding GetHashCode and Equals
I'm creating a class to wrap a list of Mask and I'd like to know if I'm overriding the GetHashCode() and ...
1
vote
1answer
54 views
A utility class for running up to two Tasks serially, where the last task to be queued “wins”
Edit: Use cases for this class - I needed this class in the case where I had processes I needed to execute (in the form of tasks - they were all asynchronous) that I needed to issue to a UI control ...
5
votes
1answer
40 views
Download file and connect: if any of both fails, go to step one
(I've improved the code from my last question)
My program....
Downloads a file (web tracker)
Update if version is lower
Connects to a server using the tracker information
If one of these ...
1
vote
2answers
37 views
Validate and Add Service Provider/Location in C#
I have a button that will validate the textbox for the service provider and the dropdown list for the locations. I have 3 tables: Locations, Service_Providers, and Service_Providers_Locations with a ...
6
votes
2answers
304 views
Unit Testing Search and Sort method(s)
I just decided to write a unit test, and see how to do it. This is my unit test:
...
-2
votes
0answers
22 views
4
votes
1answer
34 views
Rebase values in an array to match the chart scale
I have 2 long[24] arrays. Both of them contain values for each hour of a day. One of them has hit count and other queue times. Now queue times in ms are 5 digit ...
0
votes
3answers
52 views
Choosing a Base Descriptor
This code is very large and seems quite confusing. I tried to refactor it to make it more readable and make the code seem less...(scroll below). However, I am not sure if this can be refactored more.
...
0
votes
2answers
41 views
Questionnaire design puzzle
I am designing a small questionnaire web service application but however I would like if someone can look at my design and see if it good approach I am taking.
The application has the following ...
1
vote
2answers
99 views
100 doors exercise code using C#
Can you please check my code if it is correct for the problem 100 doors?
This is the problem:
You have 100 doors in a row that are all initially closed. You make 100 passes by the doors. ...
6
votes
2answers
199 views
Rubberduck VBA Parser, Episode VI: Return of the Abstraction
VBA comment syntax is fun... and VBA line continuation makes it even more fun.
Picture a VBA module like this:
...
8
votes
4answers
104 views
Multiple 'using' statements in method implementation
I'm learning WebAPI framework for ASP.NET and C#. Is the following way of handling incoming data correct?
...
-1
votes
1answer
34 views
Refactoring the following methods to make it easier to read
Would it be possible to refactor the following methods?
If so - how would I go about best doing it?
...
0
votes
1answer
62 views
XML document parser with XPath
Here is my simple implementation on XML parser for XML which I received from a server response. Also I've tried to use XmlPathDocument but failed to get child ...
5
votes
1answer
84 views
Better implementation of Gaussian Elimination in C#
I made an algorithm in C# that solves any system of linear equations using the Gaussian elimination. There are 2 text boxes in the program for input and output. Input is in the format of the ...
7
votes
2answers
111 views
Generic queries and handlers without reflection
I'm trying to implement generic queries and handlers so that I can make requests with simple syntax, like this:
...
8
votes
2answers
80 views
Inheriting methods of an immutable type
In my project, I have a type BalanceByBucket that is an immutable type and has a bunch of methods.
I have another class called a ...
6
votes
1answer
61 views
Download file and connect: if one of them fails, go to step one
My program....
Downloads a file
Connects to a server
If one of these operations were to fail, the program stalls for a minute and goes back to step one.
So, I would avoid recursion and the use of ...
4
votes
2answers
70 views
TCP chat application with both server and client logic in same application
Here is my simple chat program. I'm wondering whether it has an acceptable design (both object oriented design and network design).
If you want to run it, I can provide the solution folder.
...
-1
votes
1answer
29 views
What can be done to make data access code better? [closed]
I 'm looking to improve my code design. I have three entities, Order, Order Type and Order Type Items. Order can have 1-N Order Type and Order Type can have 1-N Order Type Items.
I'm working on ...
5
votes
1answer
50 views
Dynamic display of number converted to different numeral system
The program is displaying given number (right now it is only signed int) converted to different numeral system (binary,octal and hexadecimal for now).
Number can be input in the text box and the ...
4
votes
1answer
51 views
3
votes
1answer
50 views
Using list of tasks to obtain and cache data
I develop Windows Phone App with Prism framework (MVVM).
I use data caching. To get data I use proxy service. Proxy service creates two ...
-1
votes
1answer
46 views
Reducing database access time and connection count [closed]
I have 2 connections. How can I reduce this to one connection?
...
1
vote
1answer
50 views
Optimizing my program by accessing data locally instead of a remote database
I have a database with 4 tables filled with millions of rows. I have my program run on several computers computing data and then returning it to the database. The huge bottleneck in my program design ...
3
votes
2answers
152 views
Checking search buttons on click
There are 3 search fields, and at least one must be filled out. When the search button is clicked the search fields are checked, if none are filled in show the error window with the error message for ...
1
vote
2answers
55 views
Setting every element in an array to a given value
Given the length of an array and a char, I would like to replace every element in a char array with that given char.
Using a ...
4
votes
1answer
90 views
Lazy Load for multiple entities at a time
We have a system with a non standard database solution. All trips to the DB are rather expensive. We cannot use entity framework.
Currently our lazy loading is on an entity by entity basis. So if I ...
6
votes
1answer
77 views
A super string cleaner
I need a method that clean up a string considering these few rules:
Remove or not Spaces
Remove or not Special Chars
Remove or not Numbers
Descaptalize or not the string (this is don't really needed ...