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

Clarification about Event Producer in StreamInsight

I need a small clarification about StreamInsight, I know by doc's that StreamInsight can handle multiple concurrent Events. But will the event producer be a separate function, for ex: I need to watch ...
1
vote
2answers
145 views

User and role modeling

I'm working with a system in ASP.NET MVC, with Entity Framework for ORM. The application has a requirements to allow users to have different types of roles, and authorization rules will be different ...
3
votes
1answer
187 views

How to handle custom logic for multiple customers

We got a project where we have to process certain requests which the customer sends. The request is either in a generic format or in a customer format (all xml) which is then converted to the generic ...
10
votes
5answers
854 views

What's the use of .Any() in a C# List<>?

I've been discussing this with colleagues, and we couldn't figure out what the use is of .Any for any given List<>, in C#. You can check the validity of an element in the array like the ...
2
votes
3answers
136 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 ...
8
votes
4answers
10k views

Practical size limits of a Hashtable and Dictionary in c#

What are the practical limits for the number of items a C# 4 Dictionary or Hashtable can contain and the total number of bytes these structures can reasonable contain. I'll be working with large ...
8
votes
6answers
2k views

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

We have this code which, when simplified, looks like this: public class Room { public Client Client { get; set; } public long ClientId { get { return Client ...
7
votes
4answers
836 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 ...
0
votes
1answer
63 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 ...
3
votes
1answer
550 views

Can I write a cross-platform application (Mac and Windows) using C#? [on hold]

I see lots of old information on this question, and lots of articles flying around the Interwebs, but I can't tell quite where things are at. Basically, I want to write C# code that I can then ...
2
votes
1answer
69 views

Is it safe to include connection data in token?

When generating a ClaimIdentity for use by oAuth in generating a token, is it safe to include database information as a claim? My application uses a different database depending on the specific ...
-4
votes
2answers
56 views

Passing variable to static function, does it create hard copy or just reference? [on hold]

The code below will not make a hard copy of my dictionary and will not use extra memory right? public static void firstFuc() { Dictionary<string,double> myDic=new ...
-1
votes
0answers
34 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
125 views

Best naming practice for interface implementation with repetitive words [on hold]

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
224 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
284 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
142 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
95 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
45 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
125 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
184 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
33 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
76 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 ...
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 ...
10
votes
2answers
338 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
92 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
385 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
51 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
239 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
316 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
139 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
112 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
213 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
66 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 ...
1
vote
1answer
50 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
294 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
241 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
382 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
181 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
547 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 ...