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
1answer
22 views

Breadth-first search - and enumeration [on hold]

This is my try of an implementation of breadth-first expansion. ...
0
votes
1answer
22 views

Saving a collection of WPF user control layout into an XPS document

I am making an application to save a layout of user control into an .xps document. But, the export doesn't seem completed if the data is too many. I've tried to encapsulate each part with ...
4
votes
3answers
142 views

Join strings from a List<string> while also formating them

The code I have wrote works fine, this inquiry being purely for educational purposes. I want to know how others would do this better and cleaner. I especially hate the way I add the list items to ...
5
votes
3answers
369 views

Try/catch in a Tic-Tac-Toe game

I'm looking at my code and it doesn't look very efficient. I'm simply trying to catch exceptions or prevent them from being thrown in the first place. Can you please take a look and tell me if there ...
6
votes
2answers
316 views

The Bucketizer Script

This code is written in a SSIS Script Component that basically accomplishes what I previously had as a T-SQL script, that was reviewed here. I need to split a 80 character string that contains 20 ...
3
votes
1answer
28 views

Messenger supporting notifications and requests

I've written a lightweight (I think) class that acts as a messenger service between classes for both notifications (fire and forget updates to other classes) and requests (a notification sent out that ...
0
votes
0answers
27 views

Appropriate design pattern for DB side-effect [on hold]

I have a data access layer method to cancel an order. This operation should have an associated "operation history" entry. My first (naïve) implementation looks like this (c#): ...
4
votes
1answer
58 views

Speeding up Parallel.ForEach iterating through datatable and rendering report

I am attempting to speed up the processing of 5000 rows received from the database, which I then render as a crystal report, export to a byte stream and save in a database table. Currently I am using ...
0
votes
0answers
20 views

Rounding and formatting hours, minutes, seconds as HH:MM AM/PM PART 2 [on hold]

This is my issue: http://imgur.com/ZCxOEuV I have no clue how to solve it. I tried using substrings. This question is a followup to this one ...
5
votes
2answers
267 views

Implementing both poor-man's MVP and MVPVM framework

I'm actually building some kind of framework to promote code reuse without over-reusing it. Besides, sometimes as it occurs with generic types, one expects type parameters to be constrained for the ...
2
votes
0answers
35 views

Implementing JQuery style 'deferred' and 'promise' in C#

I like the pattern of the jQuery Deferred object. I like how you can call Resolve any number of times, but the listening objects will only be notified once. I also ...
4
votes
3answers
190 views

Rounding and formatting hours, minutes, seconds as HH:MM AM/PM

I have a program which is supposed to convert standard time to traditional time. (e.g: 15:24:31 = 3:25PM [rounded seconds]) I would like for someone to error check my code for me as well as give me ...
-1
votes
0answers
16 views

Map one entity to another [on hold]

I've got a lot of entities that come from the web service and I want to map them to my local entities. For that purpose I've created such interface: ...
-1
votes
0answers
27 views

Using an action array vs switch case [on hold]

I have an occasion of code in which I will draw a different set of buttons in a screen (depending on the number of the buttons). One thought (and my current implementation) is to use an action array ...
7
votes
4answers
360 views

Resizing image but keeping aspect ratio

I wrote some code that resizes an image to fit in a given box. I think that some parts of the code are not needed (for example if it's a box image). Is there a more efficient way to do this? Is there ...
3
votes
3answers
76 views

Customer contact unit-testing

I'm dealing with a damn scary function which I would wish to refactor so I could unit test it properly and improve the design. I will try to explain what it does and how it works in detail (with ...
0
votes
0answers
23 views

Best practice for looping on a collection using linq [on hold]

suppose i have the following collection IEnumerable<car> cars = new IEnumerable<car>(); now I need to loop on this collection. I need to do some ...
1
vote
0answers
23 views

Automapper - Mapping a nested collection to a list

I'm using Automapper to do some mapping from XSD-generated serialization object to more sane POCO's. I'm having an issue with a particular type of mapping. ...
4
votes
1answer
47 views

Asynchronously wait for a task to complete and do some async action while waiting

I have a long-running task. My goal is to create a method that will allow me to: Asynchronously wait for this task to complete While waiting on a task, do some async action once in a while. This ...
0
votes
0answers
22 views

Managing content in a database/file structure [on hold]

Right now I'm writing a program that helps manage content in a database/file structure. I have extended the Treeview control to allow it to do specific things I want to do in the program. At this ...
3
votes
1answer
54 views

Checkbox binding to change the ListView's items source

I am using a checkbox to filter some components on my ListView by changing the variable's content which is bound to this ...
0
votes
0answers
36 views

Optimized code for resizing image without loss of quality [on hold]

The primary goal of this code is to resize the uploading image without loss of quality, at the same time conserve memory usage of the system. ...
2
votes
1answer
72 views

Convert plain text to HTML C#

I have the ToHtml() Extension Method ...
4
votes
2answers
139 views

TapeEquilibrium implementation, performance issue

So, I took a test at Codility called TapeEquilibrium. The task description that I recieved can be seen here. I came up with a solution that worked, and I was pretty happy with. However, the ...
0
votes
1answer
41 views

Simplify IQueryable Linq to SQL query

Below I present to you an IQueryable LINQ to SQL query (used with NHibernate). I have tried to simplify this query but I could not do it. I want to run a query for searching information. Options: ...
0
votes
1answer
48 views

Seekable HTTP Range Stream

I read around for a while and surprisingly didn't find a fitting solution. I need a .NET Stream that internally issues HTTP Range requests when it seeks. There are huge files server-side for which I ...
2
votes
1answer
89 views

Optimal string literal tokenizing algorithm

I have a tokenizer, where one of the token types happens to be a C# string type. It takes a TextReader as its input, which is created from a StringReader, and it needs to support the basic stuff C# ...
4
votes
1answer
50 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 ...
3
votes
2answers
33 views

Triggered movement script for triggered objects

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
51 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
28 views

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

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
47 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
1answer
69 views

Why is loading images taking so long?

When Page_Load is executed I assign the ImageUrl which is a IHTTPHandler: ...
3
votes
1answer
68 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
94 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
49 views

Prefer simplicity over testability? [closed]

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
66 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
64 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
63 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: ...
2
votes
0answers
41 views

Asynchronous task and close sql connection

The following code compiles correctly: ...
4
votes
2answers
95 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
96 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
57 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
64 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
45 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
132 views

Sorting by patients' name or birth

Is there a way to write this simpler? ...
3
votes
2answers
184 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
107 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 ...
-1
votes
2answers
64 views

Sorting array with respect to two properties

I'm sorting with respect to Width and Length. However, Width has the significance ...