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

0
votes
1answer
51 views

Why does ObservableCollection require all changes to be made on the UI thread?

And is there any danger to making my own INotifyCollectionChanged implementation that doesn't? I'm trying to make a class library contains a Log class, which in turns contains some sort of observable ...
-5
votes
0answers
175 views

What can an algorithm look like that chooses appropriate images or songs? [on hold]

My goal is to automatically create a slideshow of images if either a directory or images or an audio file is given. In the former case, software should find an appropriate audio file from a library. ...
2
votes
1answer
107 views

Why covariance is forbidden for abstract class in C#

I've been digging in covariance and contravariance in C# and there is one thing I could not manage to understand. C# (AFAIK, as of 4 version) allows one to declare the covariant or contravariant ...
0
votes
0answers
35 views

async/await, what is the purpose of async keyword? [duplicate]

Consider this sample taken from MSDN article about the subject async Task<int> AccessTheWebAsync() { // You need to add a reference to System.Net.Http to declare client. HttpClient ...
1
vote
0answers
69 views

Change object state in different point in program

This is not about whether or not getters/setters are wrong. I understand its impact to encapsulation and that question has been raised here and SO several times already. I also do not want to just ...
-2
votes
0answers
31 views

Shadow Mapping Errors [on hold]

I recently started to create a shadow mapping system in OpenTK. I ran into a problem: The depthtexture is always completly white -> no depth. Even if the color from the shader is changed (I know it ...
0
votes
1answer
91 views

How to mock the private property of interface for UNIT testing [on hold]

//---Interface.... using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ClassLibrary1 { public interface IDummyInterface1 ...
4
votes
2answers
82 views

Stateless service classes and method decomposition

I like implementing service classes as stateless. However, I also like to decompose my logic into more, simple methods or functions. In some scenarios it seems like the two are somewhat against each ...
-3
votes
0answers
59 views

Writing C# Class on ASP.NET Website [on hold]

I've created a website using ASP.Net on Visual Studio 2013, I want to add CMS(Content Management System) to the project with classes developed in C#. I started by changing the development platform ...
2
votes
1answer
101 views

Project structure: Where to put object factories

I am working on a C# programming project in Visual Studio. I have created various VS library projects inside the VS solution containing the various components of the solution. Without giving it too ...
2
votes
1answer
191 views

Is it possible to write a regex that does one search then uses its results to do another search?

I'm searching for strings matching the pattern [A-Z]\W*[0-9]+, so that in V-2345 35A235 Q252 the V-2345 and Q252 would match. In another list, I want to find equivalent items that fit the same ...
0
votes
0answers
47 views

Implementing a one way web request/response in .NET

What is the better way to implement a request/response in .NET when dealing with just getting an xml web resource for the external source and process it to your system? By the way, to access this xml ...
1
vote
3answers
139 views

When and why would you extract an abstract method from an abstract class to an interface?

I have been asked the following question in an interview: "What is the need of an interface when you can have an abstract method within an abstract class?" Which I did not know the answer to. Could ...
-2
votes
1answer
66 views

Proffesional Systems Design [closed]

Please advise me and correct my understanding if I am in error. In my opinion, any programmer wanting to develop an accounting system should consider two approaches from the two mentioned below: ...
2
votes
1answer
209 views

Open / Closed Principle

I found this code example explaining Open / Closed principle. Code before application of principle: public class Logger { public void Log(string message, LogType logType) { switch ...
1
vote
1answer
78 views

Pattern to use (if any) to co-ordinate loosely coupled classes with strong interdependencies

I have a collection of cooperative classes whose behaviors are interdependent upon one another. But I wish to keep them loosely coupled, so I've created appropriate interfaces. I want to determine an ...
-1
votes
3answers
126 views

.Net Project architecture and DB connection

I'm looking at a new project to be developed in .Net, and I'd like to do it the right way. I'd like to create a solution with 3 parts : a front- and a backoffice, both using a the third part as ...
0
votes
1answer
192 views

Efficient way in comparing two lists

I have created two lists of objects: One is records from an xml and the other is records from the database. The rule is check if the record from an xml exist in the database then exclude. I have ...
3
votes
2answers
110 views

Is using getters in XAML view-models a bad thing?

I've recently had an argument with a colleague about using getters (without setters) in a view-model classes used by XAML. Example: public string FullName { get { return $"{FirstName} ...
1
vote
0answers
36 views

Using events and event subscribers to create windows in a desktop application

I should probably open this by saying I do mostly Web applications at work, which obviously have some major differences from typical desktop stuff. I had a small Windows Forms program I'd made for ...
0
votes
0answers
38 views

What's the most straightforward way to integrate my company's custom authentication with ASP.NET SSO?

My company has a series of WinForms applications that pretty crudely provides authentication by checking usernames and passwords directly against the database (with a little hashing). I have a fair ...
11
votes
4answers
314 views

What are the drawbacks to mapping integral identifiers to enums?

I've been thinking about creating custom types for identifiers like this: public enum CustomerId : int { /* intentionally empty */ } public enum OrderId : int { } public enum ProductId : int { } My ...
0
votes
0answers
50 views

How do you integrate separate projects into a single solution?

Background I'm a technical lead on a small team of three developers who work at a community college. Because of the nature of our environment, our projects are typically related (since the core set ...
0
votes
0answers
65 views

Parsing text with repeating blocks

I am parsing the responses from our Varnish load balancers in order to monitor the status of various nodes. One of the responses we get is text consisting of multiple blocks of data, one for each ...
2
votes
3answers
130 views

Dependency Inversion Principle - No deriving from concrete classes?

I'm not sure if I am getting this right. In order to observe proper SOLID principles, am I forbidden to inherit from concrete classes? Does that mean that every concrete class that I have more or less ...
1
vote
2answers
104 views

A generic helper class, a project specific class, and the rest of project

I have a generic helper class (1) that can be used in other projects also. Imagine something like basic handling of file and folders, something useful and DRY that always come in handy. I have ...
1
vote
1answer
68 views

How to avoid having nested generic in class

I'm working on a side project, and I turned on all rules for code analysis in Visual Studio, and I got the warning notice: Warning CA1006 Consider a design where ...
0
votes
1answer
114 views

How to let multiple threads write on the same file [closed]

I have got a text file called "vholders.txt". I am making multiple threads as you can see here ,those threads work with their own given data and at last they write their own output to the ...
1
vote
0answers
47 views

What's the best way to create a two-level library, containing a class with different levels of abilities?

I would like to create a library consisting of two layers, lets call them A and B. There should be a class "Sample" in layer A. Layer B also knows about class "Sample" and enlarges it by some methods. ...
1
vote
2answers
132 views

Cleanest way to expand a base class without explicitly mapping properties in C#

Lets assume I have following base class: public class Base { public int Id {get; set;} public string SomeText {get; set;} public string SomeOtherText {get; set;} public static Base ...
1
vote
1answer
54 views

c# extending a entity framework class

I have a Entity Framework class that was derived from the database layout. I was wondering if there was any problems by extending the class by creating another cs file and using the same public ...
0
votes
0answers
96 views

Advice on program performance after changes

So, the situation is like this: For the past two years, I have implemented a class in c# which is used to filter different fields from different tables in database (SQL), for reporting purposes. Now ...
1
vote
2answers
73 views

How to execute multiple timed intervals?

I'm having a hard time planning how to implement the architecture. The problem: > A user can save a number of profiles: > Name > URL > Time Interval Name | URL ...
3
votes
4answers
162 views

Cleanup & Arrange practices during integration testing to avoid dirty databases

I'm coding tests in C# and I settled with this structure: try { // ========== // ARRANGE // ========== // Insert into the database all test data I'll need during the test // ...
0
votes
1answer
55 views

Replace use of ComboBox with user controls

In currently developing a project where I'm going to use a lot of combobox, in order to avoid repeating a lot of code I'm planning on building a user control containing a ComboBox that retrieve the ...
0
votes
0answers
105 views

Is this approach scalable?

I am working to rewrite a legacy application (C++) to C# ASP.NET MVC with EF6 but plan to upgrade to ASP.NET Core1 and EF Core 1. The database schema is really arcane in that it has a single schema ...
0
votes
0answers
47 views

can a parallel queue empty itself?

Is there a way to accomplish this pseudo-code in C# in .NET4.5? parallelQueue.attemptDequeueFirstItem(item) success -> ( doAsyncTask(item).Success(UpdateDatabase) ) ...
0
votes
1answer
95 views

Neat way on passing interface parameter to a constructor

Having lots of Interface that needs to pass in a constructor looks messy, is there any neat way of doing it? Code snippet: public class Foo { private readonly IRepository1 _repository1; ...
-2
votes
1answer
103 views

Why are interfaces necessary in MVP design pattern?

I am trying to understands MVP using Winforms. I found this example. Why do UserModel and UserView need to implement the IUserModel and IUserView interfaces ?
5
votes
1answer
318 views

Does unused code affects the assembly after startup (Memory for example)?

Disclaimer: I come from a PHP background. In PHP, I could have thousands files, which are never loaded, if not needed, due to the autoloader feature (If some code is needed, it would be loaded) How ...
2
votes
5answers
281 views

Handling null-references in C# logic

Let's say I have an API method with can be used to calculate the sum of all orders made by a specific customer: Amount CalculateOrderSum(int customerId) { // Perform authentication to make sure ...
0
votes
0answers
112 views

Are assemblies packed into another sort of file(e.g Portable Executable) before JIT starts converting CIL into native code?

I've read that assembly is the smallest unit of functionality and that CIL code is stored in assembly along with assembly metadata.If this is true, here's my question: Are assemblies packed into ...
2
votes
0answers
49 views

Log with Application Insights only (NLog vs AI) in Asp MVC

I was going through several blog posts and stackoverflow and programmers and I am still a bit confused. You can install NLog (or some other logging lib) and start logging quite fast and then you can ...
1
vote
2answers
155 views

For what reasons Java and C# initialize static data on demand?

I am reading "The Go Programming Language" right now and I have read package initialization chapter which tells (or I read it wrong) that Go uses eagerly initialization. So in time we saw say C++ ...
0
votes
0answers
95 views

Option<T> functional type implementation and scenarios

Have you ever being implementing Option<T> functional type? It is discussed here: https://app.pluralsight.com/library/courses/tactical-design-patterns-dot-net-control-flow/table-of-contents ...
1
vote
2answers
75 views

Where to inject dependency required by all implementors of an interface?

I have an interface whose job is to communicate with repository (that implements some interface). It doesn't seem to make sense to implement this interface without receiving a repository,so I'd like ...
2
votes
2answers
129 views

Differences between Given When Then (GWT) and Arrange Act Assert (AAA)?

In TDD there is Arrange Act Assert (AAA) syntax: [Test] public void Test_ReturnItemForRefund_ReturnsStockOfBlackSweatersAsTwo_WhenOneInStockAndOneIsReturned() { //Arrange ShopStock shopStock ...
7
votes
2answers
130 views

Should `Vector<float>.Equals` be reflexive or should it follow IEEE 754 semantics?

When comparing floating point values for equality, there are two different approaches: NaN not being equal to itself, which matches the IEEE 754 specification. NaN being equal to itself, which ...
0
votes
1answer
93 views

Can I enforce the overriding of GetHashCode() and Equals() methods for users of a generic container class?

I have a container class similar to the one below (with much of the logic omitted): class Container<T> { Dictionary<T, TWrapped> contains = new Dictionary<T, TWrapper>(); ...
2
votes
4answers
211 views

Handling Multiple Collections in C#

I'm currently trying to learn C# and want to enhance my understanding of Object Oriented Programming (OOP). I'm hoping to accomplish this by experimenting with a small program that keeps track of my ...