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

learn more… | top users | synonyms

1
vote
3answers
201 views

Is this extension method any better than just casting to an int?

The following extension method was set up in some code I maintain. public static Int32 GetInt32(this System.Data.Common.DbDataReader reader, string name) { return ...
9
votes
4answers
491 views

What is the best way to initialize a child's reference to its parent?

I'm developing an object model that has lots of different parent/child classes. Each child object has a reference to its parent object. I can think of (and have tried) several ways to initialize the ...
-2
votes
0answers
19 views

OpenTK - Selection/Picking Glu.PickMatrix not sizeable [migrated]

I am using an open source OpenGL library called OpenTK, and I have some trouble with Selection Picking. The program checks a specific matrixview ( i.e. 1x1 px) and returns the number of objects in ...
0
votes
0answers
25 views

What is the best way to initialize a child's reference to its parent? [duplicate]

I'm developing an object model that has lots of different parent/child classes. Each child object has a reference to its parent object. I can think of (and have tried) several ways to initialize the ...
0
votes
1answer
107 views

IOC Between Presentation and Infrastructure Layer

Question: I would like to set forth dependency mapping from a *.config file from a project that has no reference to the project that contains the concrete class. Scenario: I'll be using terms from ...
1
vote
0answers
117 views

Better to keep JScript.NET dll or try converting JScript.NET code to C#? [closed]

Let me explain the back-story to my question: I have made a .NET program that logs into an account on a website and scrapes various pages of information. In order to login to the website, I must ...
3
votes
3answers
212 views

Interface to enumerate over files

I'm trying to design a generic interface for enumerating over a list files. Each iteration will open a file, allow the consuming code to access the file to perform some task, and then close the file. ...
5
votes
2answers
262 views

Should the sender of an event always be a generic Object?

When programming events in C#, it is advised to create a delegate in form of: delegate XEventHandler(object sender, XEventArgs e); My question is on the first argument of the delegate, object ...
0
votes
1answer
54 views

setting class members automatically like Photon Servers Operation class does

I'm wanting to mimic something that I saw in Photon Server with my application. Entity Framework does something similar. Photon Server has an Operation class. You pass it a dictionary of ...
2
votes
2answers
357 views

What is an alternative to bitwise flags?

I was trying to be smart and elegant, and I ended up shooting myself in the foot by coding my entire application to use flags to store various combinations of settings. Now, I have hit a point where ...
11
votes
4answers
2k views

Is it permissible to use explicit interface implementation to hide members in C#?

I understand how to work with interfaces and explicit interface implementation in C#, but I was wondering if it's considered bad form to hide away certain members that would not be used frequently. ...
0
votes
0answers
58 views

Nhibernate operations on a separate thread for a desktop MVVM application

I am developing a single user .net desktop application that lists numerous (over 2000) contacts sorted by an algorithm. I use NHibernate and did consider a session per use case (or conversation as it ...
3
votes
1answer
157 views

why Web API 2 has RouteConfig.cs file?

I m working on Web API project, and it is using WebApiConfig.cs file to defined routs for Web API. Web API fold RouteConfig.cs file. I have googled and they say RouteConfig.cs is for MVC routing. It ...
0
votes
2answers
268 views

Do GC generations have any purpose (for an application programmer) other than answer to “tricky” HRs' questions?

I'm using C# for a several years, never actually willing (until I really need to) to dig into its "deep" mechanics and to intervene in GC work, IL-compiled code and so on. My point is if you ever ...
17
votes
7answers
2k views

What can one do to improve readability of math-oriented code in C#, Java, and similar? [closed]

As both a C programmer and a C# programmer, one of the things I don't like about C# is how verbose math functions are. Every time you would have to use a Sin, cosine, or power function for example, ...
3
votes
1answer
202 views

How to store a potentially large amount of optional properties of objects?

I'm using Entity Framework Code First with ASP.NET MVC. This handles my database design based on the domain models within my application. As it stands, the engine I'm writing will have a website ...
-1
votes
2answers
125 views

Moving old desktop application to a robust platform [closed]

Several years ago I wrote a desktop application, a small accounting system, in Delphi 7, that is in user in a medium-sized company. The code belongs to me. I ported another Accounting system that I ...
1
vote
2answers
209 views

Decide the type of an object during runtime

I try to implement a PriorityQueue with C#: public class PriorityQueue<T> : Heap<T> where T : IComparable<T> { ... } The Heap is abstract. I have MinHeap and MaxHeap that are ...
1
vote
1answer
77 views

Tell, Don't Ask and Immutability in a non-directional network

I'm working on a small project in which I'm attempting to practice relatively strict adherence to two ideas: Tell, don't ask (TDA) Immutability The main concept in this project is a Map (as in a ...
0
votes
1answer
76 views

Strategy for creating a websocket relay?

I own a Raspberry Pi and would like to use it as some sort of websocket relay, so that all people who visit a specific webpage would be able to communicate with each other. The key thing about this is ...
2
votes
1answer
68 views

Design Question - System Integration

Guidance on good application architecture / design is not in short supply however most of the examples focus on some business object, like Customer and its behaviour and persistence. There is little ...
1
vote
1answer
187 views

Implementing a tricky REST API with ASP.NET Web API

I'm trying to build a RESTful API using ASP.NET Web API for a game, and here are the methods I have so far: /games GET /games/:id GET /games POST /games PUT /games DELETE /users GET /users/:id GET ...
1
vote
3answers
233 views

How can I mock this architecture?

This is not a very general question, so it may not exactly be appropriate here, but I could sure use a suggestion if you have one: I have an object containing a dictionary keyed off of an enum, ...
2
votes
1answer
178 views

In a generic method, what exception should I throw when a type parameter is unacceptable?

When the value of a normal parameter is unacceptable (and the requirements can't be checked completely at compile time), we check at runtime and throw an ArgumentException if the check fails. When ...
9
votes
3answers
700 views

In TDD should I have to write Test first or Interface first?

I am learning TDD using c#, as far as I know test should drive the development, that is first write a failing test after write the bare minimum code to pass the test then do refactoring. But it is ...
4
votes
1answer
175 views

Implicit Conversion Operators for Value Types in C#

I’ve come across this blog article: Implicit Conversion Operators are Bad. The article discourages the use of implicit conversion with reference types. The article describes problems caused by ...
-1
votes
1answer
105 views

SQLDatabase: Read a lot of data at once and process in memory or read the data when I need it?

I'm not sure how to approach this problem. I require a big chunk of data records from the SQL server. This chunk is based on variables, so I don't know before what records I need. I need to do a large ...
4
votes
2answers
272 views

Is it better to create thread safe subclasses or make the main class thread safe?

Say we have a class that is frequently used in a single-thread context: public class Foo { public List<Bar> Data; public virtual void ChangeData() { for(var i =0; i < ...
3
votes
1answer
117 views

How to efficiently implement this background processing chain?

I am working on an audio software that uses The EchoNest web service to identify and retrieve metadata about audio songs and I would like to have some advice on implementing a background processing ...
0
votes
2answers
253 views

What's the advantage of auto-property initializers without primary constructors?

In this chart about the features that are in or out of the next version of Roslyn (specifically, for C#), primary constructors are out, but auto-property initializers are in. The best use case I've ...
1
vote
2answers
196 views

Naming conventions DAL, BAL, and UI Layer [closed]

I am developing a typical Web Application with the following layers UI Layer (MVC) Business Logic Layer (BAL) Data Access Layer (DAL) Each layer has its own DTO object including the BAL and DAL. ...
0
votes
1answer
45 views

Custom mobile app and custom server app [duplicate]

I have this little bit simple and general question. Let's say I build an android app which requires an online server to communicate with. The thing is that I want to make the communication on my own ( ...
4
votes
1answer
390 views

avoiding multiple calls to SQL while being modular

I have a BusinessLayer.dll which calls DataAccessLayer.dll which ultimately makes the tcp connection to the SQL server. Each business layer method has a corresponding method in the data access layer ...
2
votes
1answer
94 views

Pattern to gain abstraction over assembly with no abstraction

I'm interacting with a large code base (in a single assembly) written by another department (let's call it BusinessAssembly). Precious few of the objects we need to use in that assembly use ...
2
votes
1answer
204 views

Should you reuse an Entity Framework EDMX between multiple solutions?

We currently have 1 giant EDMX for our corporate database. It, along with all of the generated POCOs, are in a separate project (we'll call it the EDMX project) which we pull in to any solution that ...
0
votes
1answer
161 views

I/O bound or CPU-bound

I have a telephony application, there is a windows service(third party product) running on a remote server. The application runs against the server. To connect the server, we have the code. public ...
1
vote
1answer
223 views

Exceptions: What to handle, what to throw

I have a custom configuration reader which performs various functions on top of .NET's CloudConfigurationManager and ConfigurationManager implementations, such as caching, type conversion, etc. The ...
3
votes
2answers
177 views

IoC as service locator

I have been wondering for quite some time on some issues while using dependency injection: In a layered application, I normally inject repositories into the application service using constructor ...
-1
votes
0answers
49 views

Best way to design a simple Library in ASP.NET and C# [closed]

I am new to the whole ASP and C# thing and have been experimenting by coding some very simple applications. An example of this is an extremly simple library application, it can function in 1 of the 2 ...
0
votes
1answer
115 views

Best practise to versioning Web Service WCF

I've a web service SOAP developed with WCF, there is a best practise to versioning it? when I change the contract I don't want to update all the client's referiments but I want simply publish a new ...
1
vote
2answers
132 views

Deriving from a class only to provide a special constructor

In our codebase, I encountered the following construct: There is a base class B, and then there is a class D which derives from B, but does not override or add any members. In fact, D is completely ...
0
votes
1answer
86 views

Folder structure or database structure for creating/editing 'files'?

As a hobby experiment I am creating a on-line tool for creating web sites with the ability to create custom HTML and CSS using a template engine for safe-use of functionality. Now I am in the ...
4
votes
2answers
428 views

Would this be a proper use of threading?

After reading various MSDN articles, tutorials, and posts on here I came up with a design for a windows service that I wanted to make sure my threading strategy is proper and won't lead to memory, ...
0
votes
0answers
61 views

WPF and data in the cloud

I need to create a WPF app that users will use on one machine and the manager wishes to use at home in the evenings. I have already suggested a web app which they don't want to do so suggested hosting ...
0
votes
0answers
61 views

Correct Command Management with IoC and MVVM

I have developed an MVVM framework that can be inherited by a project and used to back a new application. This application can then have plugins (like a CodeEditor for example) which automatically are ...
0
votes
3answers
138 views

Developing “real” synchronization [closed]

I'm currently writing a email synchronizer application that synchronizes email to a sql server database. One direction is not a problem: Fetching folders from the server (with its messages) and ...
-1
votes
1answer
82 views

Approach to send data updates to subscriber clients C#

We would want to send timely emails to subscribers about updates/changes to the database. What would be an optimum approach to this. Is considering SignalR a good path? Example: Let us say we have a ...
1
vote
3answers
315 views

Which one of these would be the better way to implement object copying in c#?

I would like to be able to copy an object and only change a few values. I have come up with two different ways to do this. // OPTION A - create a copy constructor and use property // ...
1
vote
1answer
149 views

C# Dependency Injection Placement

This is my first time using Unity so bear with me for a moment. I have a sample Visual Studio 2012 project with 4 projects (but only two of these projects will be used with Unity). This is the ...
33
votes
10answers
8k views

Why should your code not use 100% CPU? [closed]

I'm speaking specifically about a C# .NET 4 program running on Windows XP or higher, but general answers are also acceptable. Assume an already optimized and efficient program. The problem here is ...