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

-3
votes
0answers
28 views

How to implement EPPlus.dll in C# using DateTime datatype? [on hold]

Excel-C#-SQL Server datatype issue with DateTime for EPPlus.dll Library I am using this library: https://epplus.codeplex.com/ //Create type table according to database columns private DataTable ...
2
votes
2answers
162 views

When is code considered a domain specific language

Today, an interesting discussion with a colleague. We're going to create a wrapper for WCF's channels, that will handle the Close(), Abort() and Dispose() correctly. This wrapper is to be used instead....
0
votes
1answer
260 views

Clean OOP-Design: How to implement single responsibility and no procedural programming

I am currently trying to refactor a piece of C# code that is somewhat procedurally written. I want to make the design clean, object oriented and using classes with single responsibilities. The code ...
1
vote
2answers
105 views

Should I document overloaded operators in C#?

So I have been working on a C# Matrix library. I've been documenting it really good so far. The thing is I don't know if I should document my overloaded operators, I mean, it is kind of obvious, isn'...
-1
votes
2answers
118 views

Is main() function better on top of all other functions? [on hold]

My college professor told me that main functions should be defined on top of other function definitions. We should use a forward declaration in order to accomplish this (we use C at that time). So yes,...
2
votes
3answers
89 views

MVVM Commands - one command for everything or multiple commands?

In my last company, on handling view commands, in the ViewModelBase there were one central command implemented, like public ICommand ToolCommand { get; set; } And in the ViewModelBase, it's been ...
0
votes
2answers
142 views

Why is having a NotImplementedException a good thing?

C# has made a language feature of the NotImplementedException. It's added to a lot of auto-generated code, such as event handler stubs: // Auto-generated private void TextBox_MouseDown(object sender, ...
0
votes
2answers
105 views

How do you deal with a mutable buffer in a functional space?

I have a stream parsing method in C# that reads portions of a protocol frame from the STOMP protocol; the specification isn't the important part for the question though. What is important is that I ...
14
votes
7answers
3k views

What is the “right” way to implement DI in .NET?

I'm looking to implement dependency injection in a relatively large application but have no experience in it. I studied the concept and a few implementations of IoC and dependency injectors available, ...
-1
votes
2answers
192 views

Why use using-statements when you want to reopen connections? [on hold]

In a Winforms project I've been working on recently, I've been dutifully using using-statements for objects that implement IDisposable. I want to reopen a database connection, however because the ...
1
vote
3answers
173 views

Simplifying code of a calculator (help)

This is part of the code of a calculator that works on command line. It works fine and the math is correct but it's a little redundant: switch(Operator) { case "+": result = num1 + num2; ...
0
votes
1answer
45 views

MSDN - ServiceLocation Outdated Why? Alternatives?

I recently (1 month) start working in a project and as I was going through the code I saw an using Microsoft.Practices.ServiceLocation and as I searched for the documentation on that library is says: ...
1
vote
1answer
42 views

ADO.NET - Is it better to handle a combo box or label event, and where should the data be sourced from?

Context I recently wrote a final exam that required using a BindingSource object with ADO.NET to populate a number of combo box and label controls from which the user could perform basic business ...
1
vote
3answers
97 views

How do you create immutable objects with many parameters?

I need to create an immutable object but it requires several parameters to work like: class FooRepo { public string ConnectionStringName { get; } public string SchemaName { get; } public ...
0
votes
3answers
139 views

Does IEnumerable required to use foreach in collections

I have following class that didnt implement IEnumerable but working perfectly with foreach. And also , arrays are working without implementing IEnumerable. So why it is keep saying that IEnumerable ...
0
votes
0answers
30 views

Custom C# Script and Security using CodeDom

I'm making a piece of rendering software and I want to make the tools it encompasses extensible. I've built a UI that lets the user write custom C# functions for blending values. The functions (and ...
-4
votes
1answer
58 views

User Interface and code. How they communicate? Is it just an image and nothing to do with program code

down vote favorite Hi Does UI interface is just an Image created by graphics tools?. I need to know that when a user interface created to read an textbox in c#. when a text entered is it take values ...
0
votes
0answers
19 views

Bi-directionally synchronize/mirror folders over the internet

I am programming on the C# stack, but I have next to none Azure experience. We have several customers who have various processing needs on data files that reside at the customers computers. We want ...
0
votes
0answers
26 views

creating a teartown in integration test by deleting the test database and load the mdf again

I had a Friday developers debate with all my smart colleagues about Tear down process in Integration testing. They are putting a debate that getting a new database mdf file is better while during ...
5
votes
1answer
249 views

How to move from OOP object composition to FP function composition in C#

I have been working for a few weeks on a new web project and I am realizing that all I am doing is basically calculations and transformations on data, and that most of my classes do not contain any ...
0
votes
3answers
57 views

Use HttpUtility.HtmlEncode or create extension method

Should I use HttpUtility.HtmlEncode or write an extension method? Pro for using HttpUtility.HtmlEncode is that other developers can instantly see and recognise what it's doing. Pro for using an ...
0
votes
2answers
132 views

Is an empty class in some cases correct

I know it's generally a design flaw to have an empty class, yet I'm wondering whether there are some cases where it isn't to have an empty (abstract) class to group objects. Especially when ...
-2
votes
0answers
33 views

A Role Management System in ASP.NET MVC 5 [closed]

I want to do a Role Management System step by step with MVC empty. Please anyone can help? I have to do authentication too.
1
vote
3answers
248 views

Business rules design pattern?

I'm working on an interface for implementing business rules in order to improve SOLID-ity; so I can move a lot of logic out of Web API controllers and into a business library. The Common Problem being ...
-2
votes
2answers
211 views

Is it normal for a graduate to be overwhelmed when looking at other's code? [closed]

I'm a recent graduate, applying for a junior programming position (.NET). I've spoken with a few companies already, some of which I met through a recruiter. I like one of them a lot, but I'm worried I ...
0
votes
6answers
458 views

Is it easier to read and maintain code using “!” characters, or implying “Not” in the method name?

I often find that "!" characters (meaning "not" in C-based languages) are easy to overlook. So I sometimes create methods that return the inverse result. For example, instead of doing this: if (!...
1
vote
1answer
156 views

Put code on client (JS) or server (C#)

In an ASP.NET app, I've got to decide whether to put a complex piece of code on either the client in JS or on the server in C#. I've considered performance (if on server, it would be a small ...
1
vote
2answers
221 views

Most efficient method for large switch statements

Let's say you have many paths that an application can take at a certain point based on the value of a specific input (for example a simple int). Is there a certain method that is most efficient for ...
0
votes
0answers
24 views

Background layer for e-mail actions

My application features an e-mail layer (IEmailHandler) that implements various protocols (via IImapHandler, IPop3Handler etc.). Now when the user logs in, we fetch all their e-mail accounts (could ...
-2
votes
1answer
130 views

Is it better to learn a new language or a high level application of a known language [closed]

Recently I got chatting with my C# .NET professor and mentioned that over my free time I was learning Rust and it's been very interesting. To this the prof suggested me to not waste my ...
2
votes
3answers
107 views

Why aren't properties implicitly convertible to delegates

We all know that properties in C# get compiled to actual plain old methods. But unlike method(-group)s, they can't be given as arguments to other methods excepting a delegate like a Func<T> or ...
2
votes
1answer
119 views

What are the important considerations when switching from monolithic to microservices architecture in .NET?

We are contemplating breaking up our monolithic monsters into microservices based architecture progressively. We have 5 teams, each team containing 2-3 C# developers, at least 1 database developer, ...
0
votes
1answer
71 views

What's the best way to popullate a new row in a database?

Is it possible to add a new row to a database using DataSet, because when I created a new dataSet and dragged the table from the database I could see that in the dataSet methods there was one called ...
1
vote
1answer
56 views

Send messages from multiple services/application and display them in one place

Inside system I'm developing I have several Windows Services, couple of applications running in Scheduler and COM+ application that is running my custom DLL's. Some of them are running on same PC, but ...
0
votes
2answers
109 views

Private fields and encapsulation

I'm reading the head first c# book and don't quite understand what this means. "Any class can see private fields in another instances of the same class"
2
votes
1answer
103 views

Different ways of array declarations in C#

What is the difference between the following two methods of creating an array in C#: int[] arr = new int[] { 1, 2, 3 }; Array arr = new int[] { 1, 2, 3 };
-1
votes
1answer
31 views

Language cross platform that allows different socks connection per thread

Hello i'm developing an app that needs to do many requests with different socks connections. I was doing it in C# but i'm not sure how well it will work on a linux server even with .net core . Java ...
0
votes
0answers
16 views

Abilities interacting with aspects of other abilities - how to implement efficiently

In my game I want characters to be able to cast spells which deal a certain amount of damage of a certain type to other characters in the game. I also want abilities that negate an amount of damage ...
-2
votes
1answer
58 views

compare learning curve for desktop/windows(by c#) vs mobile/android(by java)?

I have some knowledge of C# (60%) and not about java and I want to choose a programming platform between desktop/windows(by c#) vs mobile/android(by java). Which one have more difficult learning curve?...
2
votes
1answer
111 views

What is the correct way to test performance of methods?

I made a few classes for processing and validating data in xlsx and csv. However, I am curious in testing how fast the methods I wrote in C# for the heavy lifting are. Here's what I currently am ...
2
votes
1answer
107 views

Event subscription in finally clause

Background My program communicates with a device that is usually asynchronous, but can sometimes behave synchronously. I have an event handler that I use for receiving the data asynchronously, then I ...
0
votes
0answers
12 views

JPA: Property/encapsulated objects instead of fields

I'm moving to JPA (JavaEE, Eclipselink) from a very large C# project. The classes were not using simple fields but Property objects. Example: //C# public class State : DataObject<State> //base ...
0
votes
0answers
73 views

Can I keep my code loosely coupled with public-facing enums?

I have some enums in a concrete API/library that will be publicly used by application projects. My problem here, is that I cannot write an interface to these enums (that I know of). I should have ...
2
votes
1answer
113 views

Where do you print IO error messages from in a console app?

I'm writing a simple console app to rename a bunch of files/folders, and I want to design this console app to be as modular as possible. The console app is as simple as it gets: Ask the user what ...
3
votes
2answers
94 views

How should I refer to data bound columns?

I work often with data-bound applications with WinForms; records are pulled from a database and updated in a client application that I write. Stored procedures are used for all database transactions ...
2
votes
4answers
221 views

Class Library - How to communicate between objects that are not aware of each other?

I am trying to improve my programming skills and knowledge and I have been doing some reading about various design patterns and youtubing videos etc. One subject I thought was interesting was about ...
4
votes
1answer
104 views

Why generic interface cannot implement dynamic type?

If it possible: IList <dynamic> = new List <dynamic>; or: class A <T> { A(T){} } class B: A <dynamic> {} . Why it is not possible to do this: class U: IEnumerable <...
1
vote
3answers
106 views

Same class and namespace name

I have a problem how to go about naming my namespaces and classes. I already figured they shouldn't both have the same name, as it causes all kinds of problems. Most notable problem for me is that I ...
0
votes
1answer
65 views

IoC, Unity: Creating a component with additional concrete parameters

I am struggling with the following issue. Let's say I have a component that performs operations on guests and rooms, and uses a number of abstract interfaces, along the lines of: class HotelManager { ...
0
votes
1answer
87 views

Why is ImmutableDictionary<TKey, TValue> implementing IDictionary<TKey, TValue>?

It looks like a weird design choice, because a Dictionary and an ImmutableDictionary are quite different write-wise. (Read-wise, they both implement IReadOnlyDictionary, which is fine*) In fact, the ...