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

What kind of solution should I use [on hold]

My Current Situation: I got many instances of same application that read XML files from shared folder. that makes many calls to read file and sometimes locking the files.. What I look for: I want to ...
2
votes
1answer
146 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
665 views

How to test model binding within an MVC controller when Bind attribute with Include list is used?

Auto-generated action methods in MVC5 make use of the BindAttribute with an Include list that contains the field names in a string literal. Example: // POST: MyTable/Edit/5 // To protect from ...
8
votes
4answers
219 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 ...
1
vote
2answers
949 views

How I could update a DB table using a POCO class bound in a DataGridView

I try to explain better using an example: I create the class Product with attibutes like that: private string _ProductCode = ""; [DisplayName("ProductCode")] public String ProductCode { get { ...
1
vote
0answers
32 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
102 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
166 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 ...
2
votes
4answers
830 views

Gathering IP address and workstation information; does it belong in a state class?

I'm writing an enterprisey utility that collects exception information and writes to the Windows Event Log, sends an email, etc. This utility class will be used by all applications in the corporation: ...
50
votes
8answers
15k views

Why should I use a factory class instead of direct object construction?

I have seen the history of several С# and Java class library projects on GitHub and CodePlex, and I see a trend of switching to factory classes as opposed to direct object instantiation. Why should I ...
1
vote
3answers
40 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 ...
3
votes
2answers
102 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
30 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
32 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 ...
0
votes
0answers
46 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 ...
1
vote
1answer
246 views

Clarification about Event Producer in StreamInsight

I need a small clarification about StreamInsight, I know by doc's that StreamInsight can handle multiple concurrent Events. But will the event producer be a separate function, for ex: I need to watch ...
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
122 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 ...
2
votes
1answer
82 views

Activity Feed Object to Notify Users

We're developing a transactional application in .NET (ASP.NET MVC, C#, Workflow Foundation, EntityFramework), and want to implement a system whereby users are notified of work that needs to be done ...
1
vote
2answers
91 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 ...
10
votes
3answers
14k views

Why does C# allow properties in interfaces?

In C#, the following code is valid interface I{ int property{get;set;} } Which doesn't make any sense to me. This seems to break one of the most important principles of interfaces: lack of ...
8
votes
3answers
1k views

Is using interfaces for datatypes an anti-pattern?

Suppose I have a various entities in my model (using EF), say User, Product, Invoice and Order. I am writing a user control that can can print the summaries of entity objects in my application where ...
-4
votes
0answers
65 views

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

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
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 ...
-3
votes
0answers
28 views

Unity3D: Player specific information [on hold]

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 ...
0
votes
1answer
108 views

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

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
45 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
5answers
268 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 ...
2
votes
1answer
60 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 ...
2
votes
4answers
134 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 // ...
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 ...
0
votes
0answers
94 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 ...
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 ...
15
votes
1answer
447 views

What is the proper way to suggest features to be added to the C# language?

What is the proper way to suggest features to be added to the C# language? For example, I would like to have an operator similar to ?? but for selecting the min or max values. I'd like a <? b to ...
0
votes
0answers
101 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 ...
5
votes
1answer
312 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 ...
-4
votes
0answers
79 views

How can I make a base class with a property that's data is inheriting? [closed]

I would like to make a base class and "save" data to it. For example: public class ViewModelBaseClass { public int UserId {get;set;} } // And than a create another class: public class MainPageClass ...
-4
votes
0answers
43 views

Asp.net MVC 4 Calendar [closed]

I was given this leave application project. So a user logs in and then is redirected to the leave form where they have to choose a leave type, leave from and leave to dates. When the user clicks on ...
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
86 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
2answers
119 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 ...
-2
votes
1answer
100 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 ?
0
votes
1answer
55 views

Secure way in authenticating credentials when Reading an xml file from the outside source

I started working on a project where I need to read and parse an xml file from a url. This url needs a credentials to successfully read the data from it, so I'm thinking while reading the file there ...
3
votes
3answers
2k 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 ...
-1
votes
0answers
87 views

The right approach to handling sequence of steps [closed]

I am building an application which has the following steps, Creating an application [business entity is : App] App has its own collection of links App also has its own collection of settings ...
0
votes
0answers
111 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 ...
10
votes
1answer
7k views

How can I improve my application's memory use? [closed]

I am writing a C# application, and can see the memory usage increasing as the running time of the application increases. Are there any tools or techniques I could monitor my application's memory ...
14
votes
3answers
3k 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 ...
56
votes
11answers
6k views

Does this class design violate the single responsibility principle?

Today I had an argument with someone. I was explaining the benefits of having a rich domain model as opposed to an anemic domain model. And I demoed my point with a simple class looking like that: ...