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
votes
0answers
24 views

Shadow Mapping Errors

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
70 views

How to mock the private property of interface for UNIT testing

//---Interface.... using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ClassLibrary1 { public interface IDummyInterface1 ...
2
votes
0answers
42 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
53 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
87 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
169 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
39 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
126 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
59 views

Proffesional Systems Design [on hold]

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
197 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
0answers
51 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 ...
0
votes
3answers
119 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
187 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
106 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
32 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
37 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 ...
9
votes
4answers
268 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
48 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
63 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
123 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
99 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 ...
-3
votes
0answers
28 views

Unity3D: Player specific information [closed]

I'm very new to Unity so sorry for stupid question. What are the best practices to store player-specific data for multiplayer games in general and in Unity in particular? Say players share the same ...
1
vote
1answer
66 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
110 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
46 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. ...
2
votes
2answers
103 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
52 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
95 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 ...
-4
votes
0answers
70 views

Authentication via PowerShell or C# to a ADFS based Web Proxy [closed]

I'm trying to invoke Web Requests through an AD FS based Web Proxy with SSO(https://www.zscaler.com/). No method, I tried is working. Always, I receive a 407, "Proxy Authentication required". Has ...
1
vote
2answers
72 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 ...
2
votes
4answers
137 views

Cleanup & Arrange practices during unit testing to avoid dirty databases

I'm coding UnitTest 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
53 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
92 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
102 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
315 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
271 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++ ...
1
vote
0answers
91 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
73 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
124 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
129 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
210 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 ...
1
vote
3answers
43 views

How to decide what instance variables to have in a class?

Most OO guides say not to store things in instance variables if they can be easily calculated, because the state might become inconsistent, and there is more code to maintain. I am trying to come up ...
21
votes
7answers
2k views

Specify optional parameter names even though not required?

Consider the following method: public List<Guid> ReturnEmployeeIds(bool includeManagement = false) { } And the following call: var ids = ReturnEmployeeIds(true); For a developer new to ...
0
votes
1answer
92 views

Best way to get push notifications to server from ms sql database

I partially found solution to my question but I'm not really satisfied with the result. My application consists of ASP.NET MVC + MS SQL Server. The case is as follows: External app saves data ...