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
0answers
36 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
40 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 ...
-4
votes
0answers
34 views

How to select a folder in treeview? [on hold]

I want to select a folder from treeview(that is in a popup windows) and click on select button to append every file in that to a listview. How to I can do this? My website is with Asp.net and c#.
2
votes
2answers
50 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> ...
6
votes
2answers
126 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
80 views

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

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
144 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 ...
19
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
126 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
48 views

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

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
63 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
47 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
77 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 ...
4
votes
2answers
204 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
107 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
231 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
235 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
285 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
81 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
115 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
186 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
80 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
106 views

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

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
161 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
164 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
89 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
182 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
23 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
321 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
59 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
358 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
123 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
46 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 ...
2
votes
2answers
236 views

Why does this use of IEnumerable, List, and Arrays seem to get modified when it shouldn't be?

I have started learning c# and am confused by the following feature. The following code uses a function Algs.Combinations(n,m) to produce an IEnumerable which contains the combinations of n objects ...
1
vote
1answer
171 views

Could a class with only auto properties could be a new language type and act like an interface?

Would it be useful define a type in C# that defines something similar to a data table so it can be instantiated but may not contain logic and also act as an interface? In addition I'm thinking this ...
1
vote
1answer
42 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 ...
2
votes
2answers
104 views

Is there any reason to write delegates/events for one class?

I have a game with such events as GameOver, GameStart, PlayerWin, etc. I only have one class that is listening on these events, for the purpose of sending these events as TCP json messages to a client ...
2
votes
1answer
72 views

Class structure for Entity Framework

I'm using EF (Code first) and I'd like to isolate the properties from the methods (many of the methods reference other libraries that I don't want my database project to have to reference). As an ...
0
votes
1answer
73 views

Is it good practice to assign an instantiated class to a static property in the same class?

I have code that was written by someone else that goes like this: On a ViewModel: public static ACertainViewModel Default { get; private set; } On the same ViewModel's constructor: public ...
-1
votes
3answers
99 views

Integer conversion with Console.ReadLine() [closed]

To read an integer from user input, you can use: int number = Convert.ToInt32(Console.ReadLine()); But why won't the following work? int number = (int) Console.ReadLine(); What's the difference ...
0
votes
3answers
137 views

C# — Is there a key/key lookup table type provided in .NET?

It seems like a pretty straightforward thing to add, but I just want to be sure .NET doesn't already provide one and save me from adding unnecessary code: I need a lookup table (like a Dictionary) ...
1
vote
2answers
91 views

How do I write a proper messaging protocol?

I need to write a messaging protocol between client and server for a game application. I need to send messages back and forth such as, Player joined a game, player left game, player performed this ...