Tagged Questions

C# is a multiparadigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform. C# is also used with non-Microsoft implementations (most notably, Mono). Versions 1.0/1.2 and 2.0 of C# were submitted and approved as both ECMA and ...

learn more… | top users | synonyms

2
votes
0answers
29 views

Is Nesting Grids a Good Idea?

I find myself nesting alot of grids inside grids in WPF. I just found myself 3 Grids deep, and stopped to think: "Should I be doing this?" Is there some kind of performance cost? Is it unmaintainable? ...
0
votes
0answers
17 views

Stream data from DataReader to the OutputStream in ASP.NET Web API [migrated]

Consider the following code from SomeApiController: public IEnumerable<string[]> Get() { using (var conn = new SqlConnection(asyncConnString)) using (var cmd = conn.CreateCommand()) ...
1
vote
1answer
40 views

Simple generic multithreaded queue

This is a simple thread safe queue that is used in a producer-consumer model. public class ThreadedQueue<TType> { private Queue<TType> _queue; private object _queueLock; ...
2
votes
2answers
82 views

How to unit test this method?

I have this method inside a class that is responsible for setting up and executing a model: public FlowJob PrepareAndScheduleFlowModelJob(string coordinates) { GeometryCoordinateString ...
3
votes
2answers
66 views

Side effects in functions that find boolean conditions

Here's an example of a logic structure I've refactored into something more complex on many occasions because I feel like it's wrong to have a side effect in a function that determines a yes/no answer ...
2
votes
2answers
134 views

Encapsulating common Try-Catch code. Is this a known pattern? Is it good or bad?

In an effort to reduce code duplication, I often use and have used this style to capture handling of exceptions on a boundary of an application: Given the following extension methods: public static ...
0
votes
1answer
45 views

Mocking the class under test with private method calls

Consider the scenario below. It covers multiple methods of my unit under test. public class OriginalSample { public bool Foo(ISomeEntity entity) { return entity.IsThatSo ? ...
2
votes
1answer
73 views

How is the design of this Singleton implementation

I did this as an exercise just to practive/improve using generics. Independent of how useful this implementation of a Singleton is, how is my coding in terms of using generics and any other aspect of ...
2
votes
0answers
24 views

Trying to improve WMSAuth C# example

I have to implement WMSAuth in C#: http://wmsauth.org/examples // The following function was copied from http://wmsauth.org/examples public static string BuildProtectedURLWithValidity(string ...
3
votes
2answers
129 views

Refactor to make intention clearer and testable

I'd like to improve the readability of the following code. The aim of this code is to apply formatting to row(s) in a WinForms DataGridView based on the Priority of an item, determined either by its ...
3
votes
2answers
149 views

Best practices for decouple classes in C#

So this is a lot more confusing than it has to be (I could just stick all of this in the main class with the ui event handlers) but I wanted to decouple this class for learning purposes. Basic ...
2
votes
1answer
61 views

Fill a collection from a database with all values filled

I have some data in a database, organized like (time, category, value), and basically, I want to show it in a histogram. But the library I use to draw historgrams only works properly if every value is ...
3
votes
2answers
87 views

Inserting and updating record using LINQ by calling a common function

I have a function named InserUpdateRecords(int flag) to which I pass integer variable which indicates the type of operation it has to perform , if flag==1 then insert , if flag==2 then update. Here is ...
3
votes
0answers
60 views

C# code to derive tangential points between two circles to create a trapezoid

These are the steps to determine coordinates of the 4 points (P1, P2, P3, P4) that make up a tangential trapezoid connecting to circles. Another way of looking at it is to think of the tangential ...
5
votes
7answers
138 views

Comparing string arrays

My code does what I need it to do, but I think I am missing the "right" way to do this with comparing the arrays. Essentially what I need this to do is compare a textbox entry against two different ...

1 2 3 4 5 49
15 30 50 per page