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
29 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
46 views

Best way to deliver new version(updates) to users of small client-server .net desktop application

I am developing small app for my client from different continent. Client will continuously request new functionality and new version will be delivered every 2 month. As I do not include some auto ...
1
vote
1answer
155 views

Could there be a use case for C# style auto-properties in Python

I've been doing a lot of work in C# recently (my primary language is Python) and I love that I can do something like public string MyProperty{ get; set; } Going back to Python I miss that sort of ...
0
votes
1answer
58 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
vote
1answer
80 views

Accepted Patterns For Base Class with both Static And User-Defined Data Sources

I have a requirement to build a 'base' profile library (in C# - NET 4.5.2) for various different internal (technical) consumers. This profile consists of metadata fields that would be shared by a ...
-1
votes
2answers
45 views

Integer conversion with Console.ReadLine()

To read a integer form keyboard I will use: int number = Convert.ToInt32(Console.ReadLine()); But why won't this work? int number = (int) Console.ReadLine();
0
votes
3answers
100 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
70 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 ...
3
votes
1answer
337 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 ...
5
votes
3answers
138 views

Should I make my own exceptions, or co-opt similar exceptions for slightly non-standard purposes?

This is a general design question, but I'm focusing on C# and .NET because those are the languages I'm working with right now. Should I create my own, new exception classes, or co-opt existing ...
1
vote
1answer
126 views

C# Refactoring Code OOD and SOLID

I’m having some questions regarding improvement of code structure and maintainability, especially regarding SOLID. These questions are specifically for this project, so I would be happy if this ...
11
votes
3answers
2k views

Should I use .ToString() when concatenating string and integer variables in C#?

int a = 1; int b = 2; int sum = a + b; string expression = "Expression: " + a + " + " + b + " = " + sum; Console.WriteLine(expression); //displays Expression 1 + 2 = 3 Should I use: string ...
13
votes
16answers
967 views

Should a c# dev switch to VB.net when the team language base is mixed?

I recently joined a new development team where the language preferences are mixed on the .net platform. Dev 1: Knows VB.net, does not know c# Dev 2: Knows VB.net, does not know c# Dev 3: Knows c# ...
15
votes
4answers
2k views

Why does C# have both out and ref?

C# has the out and ref keywords. Why are these two required? Disclaimer: I don't have deep knowledge of C#.
21
votes
4answers
4k views

How do I handle setters on immutable fields?

I have a class with two readonly int fields. They are exposed as properties: public class Thing { private readonly int _foo, _bar; /// <summary> I AM IMMUTABLE. </summary> ...
-2
votes
0answers
12 views

Problem with C# File IO in Winforms [migrated]

I'm having issues with a C# Winforms file IO. The code complies just fine, but then it returns errors on execution. The output code is here: private void saveData() { string fullPath = ...
2
votes
6answers
654 views

Replacing C with JavaScript as an introductory programming language [on hold]

I am a new teacher at polytechnic where we teach web development and basic software programming. For years, the institution where I teach have taught C as their introductory programming language to ...
1
vote
3answers
149 views

Advantage of generic base class [on hold]

What's the advantage of having a generic base class and a derived class having itself as the generic parameter on the base class. e.g. public abstract class MyBase<T> {} public MyDerived : ...
1
vote
4answers
202 views

What if the “catch” block is empty - “{}”

Is it proper to use below syntax for try catch?? try { int a; int b; int c=a+b; } catch (exception ex) { //Nothing here }
0
votes
0answers
31 views

Emulating `tail` to stream log data via asp.net mvc

In similar fashion to this bit of node.js, I'm interested in streaming the ongoing output of a text log file via ASP.NET MVC. I'm having trouble even thinking how I would implement this using the ...
2
votes
1answer
908 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 ...
-5
votes
0answers
40 views

Windows custom lockscreen program [closed]

I'd like to create a windows application that locks my screen, I want the program to have the same functionality as this program but I want to add functionality to it so I can play custom sounds and ...
4
votes
3answers
249 views

How can I add properties to subclasses and access them without casting from a superclass?

I'm trying to model a multi-dimensional point class in C#. I have about eight different types of points, and there may be more in the future. Right now, I have a superclass (PointBase) that holds all ...
0
votes
2answers
85 views

How can I check if answer the user typed in is unique in the form submission?

So, I have a form that has security questions and textfields for the user to type in their answer. I want to prevent the user from typing in the same answer to every security question selected. So I ...
0
votes
1answer
62 views

Extensions on Visual Studio 2015 Express [closed]

I used to install some extensions on VS Express 2013. We were using it to create some internal tools, one of them was Web Essentials. I wanted to start using VS Express 2015 so I could use the new C# ...
22
votes
3answers
2k views

Class with members that are mutable during creation but immutable afterwards

I have an algorithm which creates a collection of objects. These objects are mutable during creation, since they start out with very little, but then they are populated with data in different places ...
2
votes
0answers
73 views

How do I test with multiple input combinations?

I have a piece of code that I need to test, which is layered in three parts: Web API Controller Persistence/Logic Layer System calls for persistence It's the basic GET/POST/PUT/DELETE call system. ...
4
votes
1answer
120 views

Dependency Management in the real world?

Most of the examples i've see when watching anything on dependency management hit what i consider to be the holy grail in that the only dependencies on classes are interfaces that the IOC container ...
3
votes
2answers
280 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 ...
1
vote
2answers
310 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 ...
0
votes
0answers
14 views

Integrating legacy application with new functionality

We have a legacy application with, among other things, the ability to create instances classes within VB6 DLLs dynamically and call methods with varying signatures. We have no way of accessing the ...
0
votes
0answers
34 views

Building a house automation server [closed]

My current project involves house automation with extensive use of media. I am now tasked with programming a central control server. This server will take input via an android application and other ...
-2
votes
0answers
17 views

XML (de)serialization invalid characters in c#? [closed]

I have a person class with CDataContent and it may have invalid XML characters. So have created a class to help the (de)serialization, however it does not handle the XML Invalid characters in ...
2
votes
1answer
138 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 ...
0
votes
2answers
82 views

How can I show and hide a single field across my web application through a checked value?

Let's say I have a field called "FooName" and I have "FooName" in several places across my web application (ASP.NET MVC4). I have a check box that allows me to turn "FooName" on and off across the ...
0
votes
1answer
437 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 ...
8
votes
2answers
942 views

Unit Testing with massive lookup tables?

Our system is structured in such a way that we get a lot of key info for our calculations and other such logic from lookup type tables. Examples would be all kinds of different rates (like interest ...
-1
votes
0answers
4 views

(C#) sending hex over serial [migrated]

So I'm trying to send a (string?) of hex that looks like this "7E 00 00 FF 00 00 00 00 00 00 00 00 00 00 00 00 00 FF" over a serial port. My code looks like this: serialport.write("7E 00 00 FF 00 00 ...
1
vote
2answers
88 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, ...
0
votes
3answers
321 views

i++ vs i+=1 in cycles, why evaluate? [closed]

Why do most programmers use i++ in cycles? Doesn't it mean evaluate and increment. I find more logical to use just an increment i+=1, because that's all I want. WriteLn(i++); would evaluate i and ...
4
votes
2answers
124 views

Entity Framework Domain Object as Business Object

If I am not concerned with unit testing and switching my data access out at a later time, would using my entity framework objects as my business objects be okay? I have an existing database for which ...
4
votes
2answers
70 views

Need sorting method for coordinated, flattenned collection

I have a component which outputs an ICollection of the following type: public class CoordinatedInjectableValue { public int XOffset { get; set; } public int YOffset { get; set; } public ...
7
votes
6answers
6k views

Is Razor or XSLT better for my project? [closed]

I'm in the early stages in the design of a system that will essentially be split into two parts. One part is a service and the other is an interface with the service providing data through something ...
2
votes
1answer
65 views

Is there a standard way to handle assigning and managing tasks for users/groups in asp.net? [on hold]

Take for example what I would assume to be a fairly standard process flow, where certain users are assigned a role which allows them to create requests, but another group (or subset) are assigned a ...
0
votes
0answers
37 views

SignalR UI updates and group managing

I'm working on a web application and I have 2 specific questions regarding SignalR I need give the UI real-time updates (both broadcast to everybody on the hub, but also just to the original caller) ...
2
votes
1answer
113 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
votes
0answers
64 views

Why does internal instance become null [migrated]

I am trying to figure out why the assigner (myC.myself) become null after the line is compiled? Thanks in advance. namespace AequalsBequalsC { class Program { static void Main(string[] args) ...
12
votes
5answers
4k views

What are some practical uses of the “new” modifier in C# with respect to hiding?

A co-worker and I were looking at the behavior of the new keyword in C# as it applies to the concept of hiding. From the documentation: Use the new modifier to explicitly hide a member inherited ...
1
vote
3answers
143 views

Design pattern for different code behaviors according to different clients

At my company, we have a solution composed of a WinForm (multiple per client) and an API (one per client). This solution is deployed on different clients that require the solution to behave ...
1
vote
1answer
750 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 ...