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

-4
votes
2answers
37 views

Passing variable to static function, does it create hard copy or just reference?

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 ...
2
votes
1answer
42 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
120 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
215 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 ...
0
votes
0answers
44 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. ...
4
votes
2answers
138 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
277 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 ...
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
70 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 ...
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> ...
10
votes
2answers
296 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
1answer
180 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 ...
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.
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 ...
-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 ...
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
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 ...
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 ...
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 ...
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, ...
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 ...
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; } ...
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 ...
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 ...
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
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 ...
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 ...
3
votes
2answers
191 views

Unit Testing without DI

I am starting a small ASP.NET MVC project, each task on the board must come with unit tests. The project is small, just a few pages with not that much processing, so I decided not to implement DI. My ...
3
votes
1answer
81 views

Implementing a requirement with a decorator and ensuring it's usage

In a shared library I have a function that is widely used. I'm implementing a requirement for the function to override it's behavior when the entities are in a specific state. I have decided on ...
3
votes
0answers
114 views

Domain Driven Design - DataServices vs Repositories for Domain Models vs Database Models [closed]

I've been trying to refactor an old design in to an Onion Architecture in DDD style. To that point, the project went from a monolith to 4 sub-projects: /src /Project.Application /Services ...
2
votes
2answers
120 views

When should services persist data? [closed]

Is there a preferable way of when a service should persist data? Update Does this depend on if the services are public or internal? Some services take entity objects as parameters to do some action ...
2
votes
1answer
166 views

C# - design to parse and write csv and manipulating data [closed]

I've designed the below code for one of the requirement. I have to write different tests for the code and I would need feedback on where I can improve the design. Requirement: Read the customer ...
0
votes
0answers
42 views

C# Implementation of Perl MD5->Digest method [migrated]

I have this code on Perl use Digest::MD5; use MIME::Base64; $ctx = Digest::MD5->new; $ctx->add('fredy'); print "Line $.: ", $ctx->clone->hexdigest, "\n"; print "Line $.: ", ...
4
votes
3answers
286 views

Functions whose parameters are implicitly supplied

Callback functions are able to accept some parameters, but they are not explicitly declared when calling the function. How does this actually work? What is going on that allows us to pass a function ...
5
votes
2answers
169 views

Should I have a separate XML settings file for my application?

I want to be able to add some objects to my application by simply adding a XML node to a config file. Should I put it in the app.config file or should I make a separate XML config file? A node would ...
2
votes
1answer
95 views

Thoughts on having a generic, reusable grid viewmodel

I'm developing a wpf-based application and I'm currently struggling to find the best way of supporting a recurring scenario in it. This app uses grids a lot. There are a bunch of features I want in ...
5
votes
1answer
186 views

How should I test the HTML output my class creates?

As a learning project, I am trying to create something similar to the WebGrid that comes with ASP.NET MVC. Now this component MyGrid<T> looks like this: public class MyGrid<T> where T : ...
0
votes
0answers
24 views

Microcontroller oLED Display Buffering Optimizations or Alternatives For Speed?

I'm developing a UI/Layout for a 128 x 64 oLED Monochrome Pixel Display. I've got a small netMF microcontroller driving the display via SPI at 40mhz. I'm using some basic methods, like these here, to ...
1
vote
3answers
323 views

How to design a class for a fixed-length id?

I'm building an app in C# that needs a fixed-length id, which is a string representation of a hex number. E.g. "0fa5" is an example of such an id of length 4. The length would not need to change ...
0
votes
0answers
61 views

Is using a self-hosted service a viable option for launching applications from a url?

We have a third party supplied application with a button that enables the opening of another application showing related data when pressed (these applications are made by completely different ...
3
votes
3answers
75 views

Determine frequency-range that matches closest to input list of frequencies

Since this question is not about "code not working", I'm asking my first question here instead of StackOverflow. Inform me if any required information is missing from the question. Setup: I ...
1
vote
1answer
363 views

Is it possible to avoid a lot of using statements?

Lets say I have a simple code like this (fiddleLink): using System; public class Program { public static void Main() { //Dependency register logic here var service = new ...
-2
votes
0answers
17 views

Webview rendering problems with c# XAML vb 2013 [migrated]

I'm trying to create a XAML app for windows tablet and for some reason it's not displaying (some) webpage correctly. It shows up fine when I try to access the erroneous webpage using Internet ...
1
vote
0answers
126 views

How to scale a C# server application

I'm writing a pretty simple TCP server/client application for the first time. It is a personal project for education, but I really like my applications to be extendable and to scale in case the code ...
0
votes
1answer
48 views

How to handle the default time when user is selecting dates to filter on?

We have an ASP.NET application which allows users to report on their data. We have a number of reports that the user selects the start and end date from a datepicker and then we returned the filtered ...
0
votes
1answer
51 views

Linking kernel voids without CPU parse (Compute shaders)

Is it possible to parse data between compute shader voids without having to create a new buffer and cpu link (Using unity with C# interface). For example I have a kernel with position data on a set ...