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

0
votes
0answers
6 views

How can Specflow (Cucumber) test cases be run with Autofac as the IoC container?

I'm trying to adopt BDD in my organization and since C#.Net is our primary mode of development, Specflow is our best bet for "anything Cucumber". However, I've been a Spring aficionado in the past, ...
4
votes
3answers
657 views

What are the valid uses of static classes?

I noticed that nearly every time I see programmers using static classes in object oriented languages such as C#, they are doing it wrong. The major problems are obviously the global state and the ...
2
votes
1answer
35 views

Manual Dependency Injection Examples Still Tightly Coupled

I've been using AutoFac for some time now to take care of the dependency injection we're using in a web project. All is well, but I now want to demonstrate DI outside of an AutoFac context for reasons ...
-1
votes
0answers
33 views

How can i prevent page from reloading? [migrated]

My Question is: I have one page and I redirect to another page by passing Response.Redirect On the second page I am downloading file but when I am reloading page from user side it again downloads ...
2
votes
3answers
118 views

Best naming practice for interface implementation with repetitive words

I have an interface ILogFactory with some implementations like ConsoleLogFactory or NullLogFactory Following this naming pattern, a LogFactory based on NLog would be named NLogLogFactory which sounds ...
4
votes
2answers
214 views

Why override a static method of an abstract base class?

I'm working on C# code where a static method of an abstract base class is being overridden by the class that inherits the base class. Why is this being done? I thought that only a virtual method of an ...
2
votes
2answers
273 views

Strategy to avoid running out of memory in memory intensive application

My C# .NET application has to read lots of files with electrical readings. There are several calculation to be done and output files need to be generated. Due to the nature of the input it would be ...
4
votes
2answers
135 views

Fix a leaky abstraction (type checking)

I have a method that accepts an interface and does type checking on the parameter, and depending upon the type a decision is made to either send an email or an alert public void ...
2
votes
2answers
94 views

Relating an array of objects to an enumerator

How would you relate the indexes of an array to an enumerator without leaving the chance of mismatch? Example public enum difficulties { easy, medium, hard } public List<Lobby> ...
0
votes
0answers
43 views

I just want to clarify things about the behavior of Session in Asp.Net MVC

The reason why I asked this is because I want to know the basic principles about the behavior of a Session object. I'm working with session variables right now and I understand that it has a major ...
1
vote
1answer
124 views

Does an asynchronous queue make sense?

I have my first C# TCP server and client running, and I want to now manage clients further. When a client connects, they can find a random game lobby to join, but first they must be put in the queue. ...
2
votes
1answer
179 views

Help understanding modeling in domain-driven design

I've been trying to learn domain-driven design (and similarly Onion Architecture) the last week or so. I think I've got an understanding of it, but like math, I suck at extracting all of the ...
3
votes
1answer
369 views

Separation of concerns between repository and service in DDD with complex entities

This probably seems as an example of opinion-based question, but I'm actually looking for rationale on how to decide correctly, I believe there is a correct solution that can be backed by solid ...
2
votes
0answers
31 views

How do I Balance Multiple Service Contracts with Duplicate Structures

My current task requires me to use a set of web service calls to a 3rd party vendor in order to retrieve and update information. The objects used in these calls - namely the response from a get and ...
1
vote
0answers
69 views

How Should I Design Models With Deep Relationship Structures?

I am designing a web application in ASP.NET MVC, which uses ADO.NET for the database access. In the past, I generally have put together a series of classes each of which, maps to one table in a ...
0
votes
0answers
50 views

ASP.NET synchronous commands handlers

A question about DDD, for validating a Proof Of Concept. Let's say we have a webpage that triggers a Domain Event. For instance, updating the status of a client after an interaction occurred on that ...
8
votes
4answers
9k views

Patterns and practices for Web Scraping in .Net (C#) [on hold]

I will be putting together an application to automate an external web site/application. In some instances I will need to navigate the site as a user would (some links I need to follow cannot be ...
9
votes
2answers
269 views

Is creating a new List to modify a collection in a for each loop a design flaw?

I recently ran in to this common invalid operation Collection was modified in C#, and while I understand it fully, it seems to be such a common problem (google, about 300k results!). But it also seems ...
1
vote
3answers
91 views

C#6: Should I refactor my code using Resharper for the new features? [closed]

C# 6 is here for a while now and brings with it some syntactic sugar that Resharper is kind enough to highlight and recommend that I "migrate to". Should I apply these fixes automatically to the ...
2
votes
2answers
384 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 ...
2
votes
1answer
1k views

Separation of retrieving data and business objects between DAL and BLL Layers

I did some research before posting this question. Among other questions or post, one of those is provided below. I could not get a clear mind how to determine.. Business Objects within a Data Access ...
7
votes
6answers
17k views

What's the point of passing a parameter by reference in C#? [duplicate]

Possible Duplicate: Why are objects passed by reference? Doesn't C# send the objects themselves? So unless it's some kind of swap function for primitive typed variables - why would I send ...
33
votes
11answers
14k views

Is catching general exceptions really a bad thing?

I typically agree with most code analysis warnings, and I try to adhere to them. However, I'm having a harder time with this one: CA1031: Do not catch general exception types I understand the ...
-2
votes
0answers
50 views

Builder Design Pattern : Accessing/Passing model data in/to Concrete classes [closed]

First of all Sorry for question if its completely wrong, i am new to Design Patterns. I asked this question here also ...
4
votes
4answers
237 views

Should an application configuration interface be broken into multiple interfaces to reduce feature creep?

My windows service is neatly separated into 5 components - each with their own interface and pulled together by a bootstrapper. One of my requirements is to provide configuration options in my ...
20
votes
1answer
1k views

Why do arrays in .Net have Length but other collection types have Count? [closed]

In C# for example, arrays have Length property. But other collection types like lists, etc. have Count property. Is there a reason why these two are different? If so I would like to know.
3
votes
2answers
315 views

Integration testing and database connection string in app.config

I am working on a project where SqlConnection is created via a static method, lets say it's DatabaseAccess.GetSqlConnection(). This method reads the .config file to get the connection string and ...
2
votes
1answer
138 views

C# try/finally for state cleanup

Is there any reason (for instance: performance) against moving state "cleanup" code in a finally state? Example: this.state.InProgress = true; // logic here this.state.InProgress = false; With ...
41
votes
13answers
10k views

Why are /// comment blocks important? [closed]

Someone once said we should prefix all our methods with the /// <summary> comment blocks (C#) and I am wondering if that is true or not. I started to use them and found they annoyed me quite a ...
1
vote
2answers
322 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 ...
1
vote
0answers
111 views

Integrate C++ DLL with C# GUI asynchronously (design issue)

This is more a design than an implementation question. I am aware of how to integrate a C++ DLL within a C# main app that acts as GUI. Believe me that I've read all other questions on similar topics, ...
3
votes
2answers
212 views

When is it appropriate to use expression bodied members? [closed]

C# 6 introduces expression-bodied members, which allow for simplified code in methods and properties that only return the result of an expression: public override string ToString() { return ...
2
votes
0answers
65 views

Seperate settings and implementation class hierarchies

We use XML serialization to store class settings. Each setting-class has (but doesn't reference) corresponding implementation-class. Therefore we can easily make a "settings dll" without any ...
7
votes
6answers
2k views

How to implement a property on class A which refers to a property of a child object of class A

Not a very large architectual decision, but nevertheless I would value your opinion. We have this code (rest of the code is left out) public class Room { public Client Client { get; set; } ...
1
vote
1answer
49 views

Does ReaderWriterLockSlim provide thread safety and speed efficiency (compared to a traditional lock) when using a List?

I have a list, to which I write once in every update Loop and then I spawn some tasks which create read that List and create a duplicate to manipulate that data. More or less it's List.ToList() call ...
2
votes
3answers
293 views

Why Session has implemented this way in Asp.net

I'm not a Asp.net/C# developer myself but recently had to slightly refactor a Asp.net/C# project and I had to use Session at some point. When working with the session, regardless of the data type that ...
1
vote
1answer
78 views

How to create a re-usable, command based messaging system

I am having trouble writing a simple command based system for a chatroom. I want users to be able to do chat actions such as /j myChatRoom or /join myChatRoom /w user12 Hello or /whisper user12 ...
2
votes
4answers
240 views

Good practice for holding immutable data

I'm wondering what is the best practice for holding immutable data, more specifically in C#. For instance, lets say I have an immutable object called Foo. public sealed class Foo { public int ...
5
votes
1answer
373 views

Token or ASP.NET Identity based security in ASP.NET Web API 2

Background I have a Web API 2 project, without any extension of ASP.NET MVC or ASP.NET projects. The API will only be used to communicate between the server and Windows 8, Windows Phone 8.1 and iOS ...
3
votes
1answer
179 views

What does “Stateful” means in Stateful ViewModel in MVVM

I was reading about some XAML patterns, and there was the Stateful ViewModel, according to what I read it has nothing different than what we as just the "ViewModel". Here's a description for example ...
1
vote
1answer
543 views

C#/.NET multithreaded application design

The application to be designed serves as a bridge between two different systems. One natively speaks TCP (RS232 actually, but there's a COM->ETH server in the line of communication) - the other one is ...
1
vote
3answers
114 views

Abstracton layer to control services access to denormalized db entity

Our db is optimized for minimum join count (partially denormalized). E.g. our User entity contains account data (nickname, facebook id, etc), user numerical statistics (total games played, total wins, ...
9
votes
3answers
8k views

How do I traverse a tree without using recursion?

I have a very large in memory node tree and need to traverse the tree. Passing the returned values of each child node to their parent node. This has to be done until all the nodes have their data ...
2
votes
1answer
127 views

Managing Massive Updates with Resource Access

I have a number of data servers that are pushing data to a main server as in this kind of architecture: These data points (points for short) are updated randomly from each server. On the server, ...
1
vote
0answers
45 views

Metrics for when to use a hash value?

I am working on a project that requires a series of flat files. I will be doing some data checking against simple date like: ID;StatusCode So a typical file might be like: 13993;R 38293;A 19349;I ...
1
vote
2answers
108 views

Issues deciding on approach to create object

I'm trying to decide what's the best approach to instantiate a particular class. Basically there are two use cases for it: instantiate it in order to save a new entry to the database and fetch an ...
1
vote
1answer
765 views

Data transfer between “main” site and secured virtual subsite

I am currently working on a C# ASP.Net 3.5 website I wrote some years ago which consists of a "main" public site, and a sub-site which is our customer management application, using forms-based ...
3
votes
1answer
600 views

Clustering Strings on the basis of Common Substrings

I have around 10000+ strings and have to identify and group all the strings which looks similar(I base the similarity on the number of common words between any two give strings). The more number of ...
3
votes
2answers
119 views

Should I use nhibernate for a one row settings table

I am using nhibernate in a quite big project. The system has a settings table which has 10 columns and one row, there is always a row and it should not be deleted only modified. Concurrency can be a ...
1
vote
1answer
84 views

Best approach to setting up test and production environments for a new project [closed]

We're a very small team of not very experienced programmers who just started a decently big project from scratch. We're using Visual Studio 2015, SQL Server 2008 and the Entity Framework. The company ...