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

15
votes
7answers
1k views

Should I accept empty collections in my methods that iterate over them?

I have a method where all logic is performed inside a foreach loop that iterates over the method's parameter: public IEnumerable<TransformedNode> TransformNodes(IEnumerable<Node> nodes) { ...
-1
votes
0answers
17 views

Using Reflection to load dependent dll in Assembly

I am using reflection to load dll "A" and display collection of values using c# project. Assembly appAssembly = null; appAssembly = Assembly.LoadFrom("c:\App\A.dll"); But there are empty values ...
0
votes
2answers
150 views

Bad Practice using Auto Generated Classes for Data Access

I've seen this before but haven't found concrete reasons. When you add Entities to your EF model, EF auto generates classes for these entities. In terms of DataAccess, why is it preferred to not ...
13
votes
2answers
2k views

Domain-Driven-Design - external dependencies in the Entity problem

I'd like to start Domain-Driven-Design, but there are several problems I'd like to solve before starting :) Let's imagine I have a Groups and Users and when user wants to join a group, I'm calling ...
1
vote
2answers
648 views

Database Context and Singleton injection with IoC

All of the below relates to a ASP.NET c# app. I have a Singleton Settings MemoryCache that reads values from database on first access and caches these, then invalidates them using SQL Service Broker ...
12
votes
7answers
2k views

Name/Fix for Production Code Whose Sole Purpose is to Facilitate Testing? [duplicate]

The linked "duplicate" question is an iffy match at best, because it's asking is pattern X OK (YES/NO) and I'm clearly already in the NO camp, and subsequently asking what is pattern X called ...
1
vote
1answer
131 views

Synchronized access to network industrial equipment

I have an industrial equipment which is controlled by a software. The software connects to it using sockets, and keeps the connection all the time alive, while from time to time sending commands to ...
0
votes
0answers
40 views

Async properties in interfaces to cater for the possibility of expensive first-time evaluation: Is this a good idea?

First of all, sorry if this post is too long. I'll start with the… Short version: Is it generally advisable or a good idea to design an interface property as asynchronous simply because we cannot be ...
0
votes
3answers
275 views

Manage ClickOnce releases for different parties

I'm struggling with release management of a piece of software. First some general information: It is a ClickOnce application I follow the release often practice There are about 30 parties served ...
1
vote
2answers
559 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 ...
1
vote
2answers
121 views

How to write a custom EventHandler class

When I started using Java, I created a custom Event class to mimic C#'s implementation of Events. Since then, I've added some other features, like event listener priorities, and cascading events were ...
-5
votes
0answers
104 views

Why should I ever implement structs? [duplicate]

Structs are value types so they're more expensive to handle. Classes are more capable that Structs. What are the reasons to ever choose to use a Struct in C#?
0
votes
1answer
146 views

Speech Recognition in the .NET framework is not efficient [closed]

I want to create a Virtual Keyboard that can catch whatever key you 'speak' and send the keystroke to the active application. The Virtual Keyboard part and linking it to Speech Recognition will be ...
-1
votes
0answers
16 views

removing padding from column transposition c# [closed]

I have done a column transposition (see first part below) and i'm working with bytes to transposition an image (for encryption purposes) because I am using a 2D array I have had to use padding to fill ...
0
votes
1answer
53 views

Is there a standard to imitating an async filestream

Im trying to replace an async filestream method, which is reading data from a Hid Device and feeding it to the UI. Ive considered writing the output into a log and then importing that log again, but ...
24
votes
11answers
7k views

Why the question “give five things you hate about C#” is so difficult to answer during an interview?

In podcast 73, Joel Spolsky and Jeff Atwood discuss, among other subjects, "five things everyone should hate about their favorite programming language": If you’re happy with your current tool ...
0
votes
1answer
164 views

Organizing Business and Presentation entities

Background I am developing a WPF project. This is the basic structure: User Interface (WPF Project); Interfaces (class library, contains all the interfaces and the entities used by the ...
-6
votes
0answers
60 views

what is good for performance in for and for each loop of c# [closed]

what is good for performance in for and for each loop of c#.
2
votes
1answer
124 views

In what way are union types better for correctness than a common interface?

I've just recently started familiarising myself with functional programming, mostly via F#, and there's one particular functional idiom that I'm not fully understanding the benefits of. I've seen it ...
-3
votes
0answers
62 views

Algorithm to find the next available index in a list [closed]

I have a list of items so for example item1, item2, item3,....item10 and then I have a list of items that are marked to be deleted from that list for example item2,item5. I want my method to return ...
3
votes
3answers
270 views

Method waits for user action

I have a structural problem for an application I'm working on. In the interest of full disclosure, it is for a university assignment so I'm not looking for you to code me an answer, just help me ...
1
vote
2answers
306 views

Application use on website

Is there a good way to run a C# application on clientside in lieu of JavaScript? I have done some front end work with JavaScript and backend C# for web developing at an old job, but I am interested in ...
0
votes
3answers
206 views

Force Derived Class to Implement Static Method C#

So the situation is like, I have few classes, all of which have a standard CRUD methods but static. I want to create a base class which will be inherited so that it can force to implement this CRUD ...
10
votes
4answers
6k views

Understanding the static keyword

I have some experience in developing with Java, Javascript and PHP. I am reading Microsoft Visual C# 2010 Step by Step which I feel it is a very good book on introducing you to the C# language. I ...
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, ...
0
votes
1answer
68 views

Which transaction manager will be used in WCF?

I am going through the transactions exist in WCF service but seeking some more clarification on this. I am not sure about which transaction manager WCF will use for following scenarios: If the WCF ...
0
votes
1answer
64 views

Inverse property naming (ORM scenario) [closed]

I have a class that represents a process. In this process there are inputs boxes and output boxes. public class Process { public long ProcessId { get; set; } public virtual List<Box> ...
40
votes
13answers
5k views

Is C# development effectively inseparable from the IDE you use?

I'm a Python programmer learning C# who is trying to stop worrying and just love C# for what it is, rather than constantly comparing it back to Python. I'm caught up on one point: the lack of ...
0
votes
0answers
39 views

How can I control the naming used when mapping foreign keys where there are more than one list of same class contained [migrated]

public class Person { [Key] public int ID { get; private set; } [Required] [StringLength(100)] public string PersonName { get; set; } } Creates "People" table ID | PersonName | ...
-1
votes
0answers
17 views

Get the Foreign Key table data along with Requested data [migrated]

I have two tables where one table Location References(using Foreign Key relation) to another Table. I am Using Dapper i want to Get the Location Details as well for the Given Customer Table. Like the ...
0
votes
2answers
274 views

Organizing solution / project structure and classes for Line of Business Application (LOB)

The question how-do-you-organize-your-projects already has a few good answers. I would like to get a better understanding about this suggested structure: MyApp.Core MyApp.Model MyApp.Presenter ...
0
votes
1answer
44 views

DAL / Model / Application-Design Question for a MVC Application

I have a device that stores raw binary log data as a BLOB in a MySQL DB. That process is a blackbox to me (closed source) which I cannot change. I know, however, how to decode that BLOB and transform ...
1
vote
1answer
65 views

Setting fields of a base class when using the constructor is not an option

I am refactoring a base class, implementations of which are plug-ins, loaded at runtime by another class using reflection. The class I am refactoring uses a user ID of the form domain\user. I need ...
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
0answers
11 views

How do I save a Winforms panel's drawing content to a file? [migrated]

I made a paint program, and the drawing content (from System.Drawing) is drawn on the panel. I attempted this method to do a simple save for now, and I only get a blank image. My bitmap has its ...
2
votes
3answers
52 views

Pre-processor usage to separate logic to different versions of product

In the .NET code base of a product, there are #if pre-processor statements to define whether certain functionality should be available. Like so: shared logic #if version1 some logic #endif #if ...
1
vote
0answers
42 views

Does using membership provider in the model of a MVC project mean the model knows it is part of a website?

My basic design is that the model is in a separate project from my website, and the project never references the website. That tends to enforce the model being agnostic of how it is being used. But ...
0
votes
2answers
150 views

How are the tiles in WORDAMENT organized?

I'm trying to create a word game, just like WORDAMENT, in my spare time. In order to present a new round, I need to create a board with 16 letters organized in a 4*4 grid. Currently, I'm generating ...
0
votes
2answers
486 views

Tree View Children condition indicator on topmost un-expanded parent

I am using a tree view in c# and i am creating custom icons for the nodes. Let say this is my hierarchy with a node that satisfies a certain condition: Root1 |_Ax |_Bx1 |_Bx2 |_Cx1 ...
6
votes
6answers
1k views

Would a “downcast if block” be a reasonable language feature?

Consider the following "if cast": class A { public void f1() { ... } } class B : A { public void f2() { ... } } A a = foo(); // might return A or B if ( a is B ) { // Inside block, ...
0
votes
0answers
44 views

Accessing a stateful managed object from native code via a static variable [migrated]

I need to create a native C++ DLL that will be an interface/wrapper over a C# class. I've never done anything like this before, but my design is basically the same as this. In other words: I have a ...
2
votes
1answer
264 views

2 questions about TDD

I'm just starting to get to grips with TDD, and I have 2 quick questions; I'm assuming that if I were writing software for a software company, that TDD would work alongside the software design? i.e ...
0
votes
1answer
69 views

What possible things to log in mvc webapp [closed]

I'm about to learn to handle logging in my c# asp.net mvc app and are going to store my log in a noSQL-db. How to handle the logging is done. The thing is I'm having a hard time to figure out possible ...
0
votes
2answers
90 views

Mocking the context of application

We have a context of the application which is a static class named Holder containing several static properties initialized by objects that are used throughout the application. All over the unit tests ...
-1
votes
0answers
37 views

How to search for requested text backwards? [migrated]

Go to Notepad. Type in "This is a test this is a test this is a test". Put the caret to the very end of the text. Go to Edit -> Find -> Type "is" -> Set the direction to 'Up'. Each type clicking ...
5
votes
2answers
8k views

Should I use a list or an array?

I'm working on a windows form to calculate UPC for item numbers. I successfully create one that will handle one item number/UPC at a time, now I want to expand and do it for multiple item ...
12
votes
2answers
879 views

How to calculate figure rotation efficiently?

I have a Figure represented through a matrix of bytes (bitmap-like matrix). Example Figure is shown on the Picture 1. The goal is to find the best rotation angle of some given Figure. When Figure ...
0
votes
2answers
520 views

How I could update a DB table using a POCO class bound in a DataGridView

I try to explain better using an example: I create the class Product with attibutes like that: private string _ProductCode = ""; [DisplayName("ProductCode")] public String ProductCode { get { ...
-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 ...
1
vote
0answers
129 views

C# structure needed for dynamic behaviour

I am using Unity to build a visualisation of a serious game. I am using the C# programming language. My problem is that I receive data from a JSON and I parse it and I end up with a list of different ...