C# is a multiparadigm, managed, garbage-collected object-oriented programming language created by Microsoft in parallel with the .NET platform
0
votes
1answer
19 views
storing single character value use string or int C#
While storing single character value for the purpose of status, gender, delete_flag etc. which is better data type string or int. Suppose ::
status = A/I or status = 1/0
gender = M/F or gender = 1/0
...
0
votes
0answers
48 views
How to enforce type safety between dependencies using generics and dependency injection?
What I'm really looking for is an answer that provides a way to avoid compromising the code's complexity to achieve type-safety when using dependency injection and collaborating generic types.
For ...
1
vote
0answers
27 views
Modular Filter Architecture for WPF
I am creating a little stock-management tool for private use.
I have different views, which need similar but different filters.
As an example i have a "current stock" list where i can filter for ...
3
votes
2answers
127 views
When to use Constructor and when to use Collection Initializer? (In C#)
I am having a .Net class which has 10 properties like given below: [the datatypes of individual property is just a placeholder here and it can be anything from a primitive type to an object to a list ...
0
votes
0answers
30 views
Multiple TCP port requirement for a client-server relationship
I designed a basic C# TCP sever that listens on some port. I extended this into 4 other servers that perform very different tasks, but together make up one product. The client needs to connect to each ...
42
votes
6answers
4k views
Why would you not use the 'using' directive in C#?
The existing coding standards on a large C# project includes a rule that all type names be fully qualified, forbidding employment of the 'using' directive. So, rather than the familiar:
using ...
3
votes
2answers
111 views
Deep SQL relationships to a C# object model
I have a database with deep table to table relationships
for example
Clients (one to many) -> ClientData (one to many) -> ClientJob (one to many) -> ClientProcess (one to many) -> ...
25
votes
4answers
3k views
Does C# 6.0's new null-conditional operator go against the Law of Demeter?
The Law of Demeter states the following:
Each unit should have only limited knowledge about other units: only units "closely" related to the current unit.
Each unit should only talk to its friends; ...
1
vote
0answers
26 views
Pattern for interface between sequence executing object(s) and sequence configuration objects
My motivating case is hardware test automation. We have several different testers (benches of lab equipment that connect to the "device under test" (DUT)), and we write test configuration files which ...
1
vote
1answer
31 views
Throwing exceptions in application configuration providers
Simple question: What is the best/common practice regarding to throwing errors for application configuration providers?
Given is a simple key/value-based configuration source:
class Configuration
...
0
votes
0answers
28 views
Enforce No Multiple Async Entity Framework Operations
We are working on a large-ish MVC web application with multiple backing stores including a SQL Server database accessed via Entity Framework 6.0. We are using asynchronous operations wherever we can, ...
3
votes
1answer
125 views
Cleaner Windows Forms
Backstory:
I am working on a Wizard Setup project and I've ended up with a very big(a lot of lines of code) Form class. Because my form holds a Wizard control which in turn has lots of pages and each ...
4
votes
1answer
626 views
Why is there not a basic SortedList<T>?
As far as I know, there is no way to get a List<T> with the capacity to sort itself. If I add a element, I want the data-structure to insert it in the right position (based on the associated ...
1
vote
0answers
51 views
ASP.Net MVC - Implementing a Test Environment
I would like to implement some sort of test environment for ASP.Net projects. I am trying to implement this as an alternative to mocking the entity framework.
Here is what I am trying to achieve :
...
2
votes
2answers
150 views
Using a private auto-implemented property vs. a private field
If I have a need for simple, private fields, is there any reason I shouldn't just make it a convention to use private, auto-implemented properties instead?
For instance, I could do this:
private ...
0
votes
0answers
75 views
Should I be using a design pattern when creating these objects?
I have a lot of duplicate code in my program that basically follows this structure:
If condition is true
Create ErrorRecord object
Call ThrowTerminatingError(error object)
End if
The ...
2
votes
2answers
73 views
Making a security on webapi for browser usage [on hold]
I have a webapi project working in production for few months now.
The entire webapi is server to server.
There is a need now to have the same functionality in a browser, meaning the customers ...
0
votes
3answers
106 views
Update XML file versus overwriting XML file [on hold]
I have a console application that will make modifications to 1200 systems remotely using SCCM. One of the items to be modified is a GUI menu app that is XML driven to display buttons that launch other ...
4
votes
1answer
90 views
Overriding == for immutable collections
Suppose I have a class that is a readonly collection or immutable objects, e.g.
public class ReadOnlyInts : IReadOnlyCollection<int>
{
private readonly IReadOnlyCollection<int> ...
0
votes
0answers
28 views
ModelState Validation vs JQuery vs Remote
I was stuck with some validations for quite a while. I have been thoroughly searching the internet to find ways to apply the validations I require. I came across many methods for validations even ...
6
votes
1answer
153 views
Never using Models, only ViewModels
I'm starting a new MVC 5 project from scratch. I'm using EF 6 (Database First) and Identity 2.0.
My solution consists of 3 different projects: Data (where I have a .edmx and my DB context), Resources ...
-2
votes
0answers
32 views
C# 2D platformer movement code [migrated]
This code will keep on jumping even though it is not on the ground how do you stop this (using Unity)
The Code:
using UnityEngine;
using System.Collections;
public class PlayerController : ...
0
votes
0answers
21 views
How can I cleanly handle a several permutations of Resource Request, (Optional) Login Control, Resource Result?
Whenever a user interacts with a resource while not logged in, I need to:
Redirect them to a secure page.
Show a signup/login dialog (which is usually partially customized based on the resource, ...
2
votes
3answers
291 views
Which C# data structure should I use to quantify this information?
I am attempting to determine which data structure I should use for the following information:
("Water", 100F, 0F, 0F, 0F, 0F, 0F, 0F, 0F, 0F, 0F, "");
("Tuna", 60F, 184F, 30F, .01F, ...
-4
votes
0answers
43 views
Regarding capturing geotagged image in asp.net web application using mobile device [closed]
Basically it's a asp.net web application.
We need to read the records(cases) from excel and store in DB.
These records (cases) will be displayed in a grid and using check boxes we will allocate to ...
-1
votes
0answers
38 views
Looking for image Blob detection algorithm examples [closed]
I am looking for some code explanation on how image "blob" filters work, preferable in c#. There are several methods I read about. And I've looked at Aforge (and tested it) EmguCV, OpenCV, and I've ...
3
votes
1answer
89 views
How to represent very specific business logic in classes containing the business logic?
BusinessModel: I have a ice cream shop and I designed classes to do my supplier based financials based on industry types(Lines of business). I sell ice creams of many types, which I buy from different ...
2
votes
1answer
90 views
Struggling about the benefits of using a plugin approach in a Industrial Software Architecture [closed]
I'm trying to design an application, something quite generic over a .NET C# Stack.
It's supposed to be an desktop application intended to control industrial equipment and to perform measurements and ...
2
votes
2answers
262 views
Does class inheritance (in C#) violate the Open/Closed Principle?
I typically make all my methods private unless and until they need to be overriden by a sub-class. At that point I modify the base class to make that particular method protected virtual. Is it ...
1
vote
2answers
219 views
How to solve this inheritance problem
I have the following classes:
public abstract class StaticFileController<File, QueryData> : AsyncController
{
private string _resourceName;
public StaticFileController(string ...
0
votes
1answer
79 views
Program uses an older version of dll rather than the one embedded in the exe
I have a project for which I used to deliver an additional .dll file.
At some point, I have installed Costura.Fody package and started embedding this .dll in the .exe file to get a one-file standalone ...
2
votes
2answers
158 views
Await state async
For speed we sometimes return response to consumer before state is saved in DB. Sometimes (Mostly for our automated consumers) this can break because the want to make actions on the saved data before ...
1
vote
2answers
167 views
Understanding a project architecture
If I develop an application, I'll often use a project structure like this:
MyApp.DataAccess.Implementation
MyApp.DataAccess.Contract
MyApp.Business.Implementation
MyApp.Business.Contract
...
1
vote
1answer
97 views
Code First Approach and Business Classes Validation
I have a solution split into two projects : A class library containing all of my model classes (lets call it Business), and an ASP.Net MVC project.
My Business classes are meant to be generic and ...
-1
votes
1answer
128 views
Programming Pattern - Single Data Structure - Multiple Methods [closed]
I have a single data structure that holds a relatively small amount of objects (ca. 1500) and several methods that are acting on it. Is there a programming pattern to iterate the methods over the data ...
12
votes
4answers
4k views
Why is .NET VM based? [duplicate]
Java has been designed to run on a virtual machine to allow portability for programs.
However .NET has been designed from the start specifically for Windows.
Than what is the reason for .NET ...
1
vote
2answers
134 views
Performance concern in object oriented languages [duplicate]
I recently moved into web development using ASP.NET MVC. The language I use is C#. Having considerable experience in C makes me look for optimized coding standards (memory, efficient data structures ...
-2
votes
0answers
25 views
Open Embedded Textfile using notepad [migrated]
I have the following problem. I want to open an embedded textfile (agb.txt) using "notepad.exe". I've got the following code:
private void linkLabel4_LinkClicked(object sender, ...
18
votes
1answer
805 views
What are the standards for dealing with pluralia tantum in your code? [closed]
When using variables of which their plural and singular are both the same, how do you name them? Are there any standards out there?
For example:
Series[] series // Plural
Series series // ...
3
votes
3answers
52 views
How to design access to different type objects in protocol response
I have written a communication library for an industrial device protocol. The response frame contains a byte array as payload data.
The payload data consists of several "objects“ of different types, ...
0
votes
0answers
154 views
Credit Card Equation (in C#) [migrated]
I have a homework question that I need some verification on. I got the correct answer for the first part of the question. However, the second part of the question isn't working out so well. I'm not ...
2
votes
5answers
151 views
Creating variations of a property heavy class
What kind of pattern or design can prevent the creation of a class packed with properties that aren't always used?
Example
class Car{
public string type;
public string name;
public DateTime ...
1
vote
0answers
44 views
How do I debug a powershell script executed from C#? [migrated]
I have code running a powershell Script though the use of the System.Management.Automation namespace in C#, similar to the code below.
using (mPowershell = PowerShell.Create())
{
...
1
vote
0answers
41 views
Best way to modify items in ObservableCollection with a form [migrated]
I have an application that collects data in the background, displays data with one window, and has another form that can be used to update data objects. Data is stored in an observable collection that ...
5
votes
1answer
198 views
How to populate Lazy object from database
I have these classes:
public class Order
{
private Lazy<IEnumerable<Volume>> _volumes;
long ID { get; private set; }
string Description { get; private set; }
...
-2
votes
4answers
251 views
In C# Is using private constant strings better than using strings directly in the code? [closed]
Consider the following two cases:
case 1:
class A
{
private const string MyConst="Hello";
internal void CallMe()
{
System.Console.WriteLine(MyConst);
}
}
Case2:
class A
{
...
1
vote
1answer
98 views
Common Repository design
What I have:
I am developing an Active Directory layer which will be used by a huge application with several modules having several solutions and projects...
I am fairly new to developing large ...
-1
votes
0answers
27 views
Pass a value from View to action in another controller(using Viewmodel) [migrated]
I want to pass a value from my current view to action method in another controller. I have used ViewModel to pass the values of both the classes. But now I want to pass a particular value from the ...
3
votes
1answer
162 views
Onion architecture in client-server application
I'm staring new project, cross-platform. I want to use onion architecture there. It will be a simple game (tic tac toe), just for education purposes. This app will be client-server type.
Now, I read ...
4
votes
0answers
114 views
How is one supposed to deal with the intermediate buffer of DataReader class?
Summary
I am developing a WAV file format reader under WinRT, and for this I need to read random amounts of structs consisting of fundamental types such as int, uint, float and so on.
Back in ...