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

-2
votes
0answers
46 views

Does the user need to install CS script himself if i use it in my C# program? [on hold]

The current program i am making has come to the point where i need to include some kind of scripting. Looking at the avaliable stuff CS script seemed the best solution for my problem. Now the problem ...
2
votes
1answer
112 views

Where to store configurable, global settings

As an example, let us say that I have an application with multiple users and multiple administrators. I want the administrators to be able to configure sitewide session timeouts. The code would ...
-4
votes
0answers
37 views

C# console app which calculate a volume of a box [on hold]

I'm new in C# and I'm trying to make a program which calculate the volume in decimals of a box. I made something but is not working. I would like to know what is wrong and see a solution. I need to ...
1
vote
2answers
97 views

DLL or web service for common functions?

We have a variety of basic functions (date utilities, email sending, internal math calculations, etc) that are currently in an old VB.NET project. We're going to move towards C# and I'm wondering if ...
4
votes
2answers
173 views

C# obtain derived class from base

I am trying to build a dashboard that allows a variety of widgets to be displayed on the home screen. They are structured as follows: public abstract class Widget {} public abstract class ...
2
votes
1answer
108 views

Call method in a disposable object at the beginning of a “using” statement

When we use the lock statement, it is essentially doing a Monitor.Enter at the beginning of the locking block and a Monitor.Exit at the end of the block. This process is automatically handled by the ...
0
votes
0answers
34 views

Class design for an app that reads data from Active Directory

I am hoping someone can help me regarding design and architecture for an application. The application is basically a service written in C#. The purpose of this service is mainly to read data from ...
1
vote
3answers
164 views

Using prefix/postfix increment operator for simple incremental array access rather than actual index numbers

I cannot decide which method is better with consideration of both readability and fault-tolerance. Method #1: Object[] objects = getArrayOfKnownLength(); int i = -1; someMethod(objects[++i], ...
2
votes
2answers
177 views

How to iterate between these elements

I have an array of elements: int[] elem = new int[] {A, B, C}; I need to calculate the sum of ALL the combinations of those elements, where only some of the elements can be optionally selected. I ...
-3
votes
0answers
26 views

Microsoft.Reporting.WinForms VS2013 Missing [closed]

I've found several answers to this - Most involve running the REPORT VIEWER 2012 RUNTIME from https://www.microsoft.com/en-us/download/confirmation.aspx?id=35747 Been there done that. Doesn't show ...
5
votes
3answers
216 views

When should I use C#'s implicit type conversion operator?

In C#, we can overload the implicit conversion operator like this (example from MSDN): struct Digit { /* ... */ public static implicit operator byte(Digit d) // implicit digit to byte ...
0
votes
0answers
39 views

Pushing data into chunks from server to mobile client

I am developing a windows phone application. On the first screen user enters some unique code and based on that code there are say 200 or more records on the server which I want to return to the ...
-2
votes
0answers
121 views

How do people get into .NET development? [closed]

I ask if anyone knows of any research into how .NET developers (c# or VB.NET) got into .NET (opposed to Java, iOS, etc). I have a couple of theories but I'd like to be a little more solid on the ...
1
vote
2answers
295 views

.NET Why should I use DAL over direct database access

Yesterday on one of SO chats I've been told I should never connect to database directly from the application and rather use DAL. I've been told that: 1. Using something in the middle should improve ...
-1
votes
0answers
35 views

Tcp server language choice [closed]

Is there any reason to use a specific programming language for TCP server programming? Or java, c# can achieve same as c++ without any noticeable performance loss?
7
votes
2answers
324 views

Big O equivalence for LINQ select

I'm trying to determine if there is a change in the Big O equivalence of a nested loop when I use a LINQ select instead. public void myFunc(List<Foo> fooList, List<Bar> barList) { ...
0
votes
1answer
67 views

Why is it faster to compact a portion of the managed heap than the entire heap?

I was reading this article on MSDN. In the first paragraph under the "Generations and Performance" subheading is written: First, it is faster to compact the memory for a portion of the managed ...
2
votes
1answer
113 views

How do you handle saving blog tags in MVC?

I'm writing my own blog engine as a learning exercise. The blog is fairly functional right now but I'm trying to add a 'tag' feature to it and I'm confused as to what the best way to handle saving a ...
0
votes
3answers
235 views

What arguments are there to use a coding style for each distinct language? [duplicate]

I recently had a discussion about our coding style for C# projects. Two things in particular were very hard to agree upon. Method Naming C# has the de-facto standard of naming (at least public, ...
2
votes
2answers
68 views

Share some fields but others unique to owner of instance

I've been programming for many years and this is sort of a strange need and I've never seen anything like this but I have a game where there are abilities that you can do. There is an ability class ...
2
votes
2answers
251 views

Refactoring long methods with a lot of cyclomatic complexity

I'm attempting to refactor what is becoming a very large method -- currently 350 or so lines -- that contains a high degree of cyclomatic complexity. I understand and ascribe to the theories that ...
6
votes
3answers
262 views

How to explain design decisions when refactoring code

I am working on a colleague to refactor the following code, I am trying to turn this into a teaching experience as well. Original Code public class WidgetRepository { public Widget ...
0
votes
1answer
61 views

c# class generation/architecture for json rest service

I want to consume part of the Steam WebAPI, it's a simple Rest Service but it produces some complex json. I thought about using the Newtonsoft Json.Net Library generate my c# objects. Whats the best ...
-2
votes
0answers
59 views

OOP vs ADM Comparisom

This is the ADM equivilant to the example code given in Correct placement of Methods in OOP In this example we have resolved the Method placement question by moving ALL methods away from the data, ...
1
vote
4answers
256 views

Why I need to make method of my class private, If I need to access it throughout my application?

I am going through the beginners tutorial for C# from a website http://www.homeandlearn.co.uk/csharp/csharp_s10p1.html On chapter of classes, it makes the method of class private and then use ...
1
vote
3answers
173 views

c# application to read xml files, parsing them, storing locally in data structure and writing to csv

I have to develop a c# application that will read large xml files. XML files will have data about computer systems (i.e. Hardware, software, network, bios information). There will be separate xml file ...
2
votes
4answers
172 views

Failover for High Frequency Jobs

I have a job that runs at a fairly high frequency (~1x every second). This job needs to be executed constantly as long as the web app is running. However, I really only want 1 instance of the job ...
3
votes
1answer
260 views

Correct placement of Methods in OOP

Which Class should contain a method which has dependencies on multiple classes? I've coded up a specific example to avoid generalizations. In this example we have an initial requirement : ...
3
votes
4answers
254 views

Design method to return List of objects

I need to create a method which will return a List of IRule objects. This is what I have written, am I correct in the approach? Or should I follow any patterns/principles? public IList<IRule> ...
0
votes
0answers
60 views

Multi-threaded winforms with multiple child forms using sockets

I develop application with two main option grouped by groupBox in main form. First option is run server with specific behaviour for example I choose TCP protocol, type IP address, port number and ...
3
votes
3answers
318 views

Functional vs object-oriented style in C#

I'm learning functional programming and face the following confusion when applying it to my C# projects: I begin by writing pure, static functions and use function composition. After the code ...
0
votes
0answers
30 views

C# - Array.Find() not assigning a struct return value [migrated]

I am attempting to use Array.Find() to return a structure, from an array of structures, and assign it to a structure named Result. However, Result's values never change from null (I ran it though the ...
1
vote
1answer
128 views

Should I use: One event multiple subscribers or multiple events multiple subscribers

I am writing a data acquisition application. I wondering whether I should use one event multiple subscribers or multiple events multiple subscribers. I am worried about performance. Also could I ...
-4
votes
1answer
177 views

Why is one language with elegant easy to read syntax as fast as one with the verbosity or explicitness? [closed]

There are 2 distinct types of programming language design categories in my eyes. We have C++/Java/Rust/C# languages on this side, Fast for the most part but also a bit verbose or explicit. On this ...
0
votes
0answers
69 views

Is using Interface implemented by single class a not recommended practice? [duplicate]

I have several classes in C#, not just POCO class but with methods and implementations. Each of those classes implement one Interface. e.g. IPerson implemented by Person class. Employee implements ...
15
votes
7answers
1k views

What's the idea behind naming classes with “Info” suffix, for example: “SomeClass” and “SomeClassInfo”?

I'm working in a project which deals with physical devices, and I've been confused as how to properly name some classes in this project. Considering the actual devices (sensors and receivers) are one ...
0
votes
0answers
42 views

Using regions in C# applications [duplicate]

What is cons and pros using #region - #endregion tags in a C# application? Generally people are asking as disadvantages of using #regions. But I am asking if there is some advantages of #regions. I ...
2
votes
0answers
50 views

Argument over performance using Convert.ChangeType in Web Applications [duplicate]

A debate has been going on at work about using Convert.ChangeType. A couple of fundamental assumptions to this discussion are delineated below: 1. The discussion is within the context of web ...
2
votes
1answer
54 views

Which approach for coding a 'texture atlas'?

For a game project, I have a couple of textures coming from multiple sources and I need to pack all these within a single texture atlas. Example for a racing game circuit, there are textures for : ...
1
vote
2answers
149 views

How to unit test static void methods? [duplicate]

How does one go about unit testing static void methods? I have a few more questions: Is it necessary to unit test database queries like insert, select and update queries ? If so, how does one test ...
0
votes
1answer
91 views

A CLR SQL Server Stored Procedure calling an ASP.NET Web API

We are developing a big system with SQL Server database, ASP.NET Web API 2.2 services and another external services. We need to load more data on a table while we process the current data on it. To ...
4
votes
4answers
323 views

Legitimate cases of having .equals() behaving inconsistently with .compareTo()?

Java documentation says it's "strongly recommended" to have them behaving consistently. But are there legitimate cases of java/c#/python/etc Object.equals() method behaving inconsistently with the ...
2
votes
1answer
67 views

Application plugin system - interfaces - adding new features

Imagine I have an application, which have plugin system. public class MyPlugin : Plugin { public override ExecuteImpl (Context ctx) { // do something... } ...
2
votes
2answers
207 views

When it makes sense to implement C# explicit operator?

Follow-up of Is my usage of explicit casting operator reasonable or a bad hack? One of the users commenting on that question said that it's really bad if the casting operator creates a new object ...
22
votes
5answers
3k views

Is my usage of explicit casting operator reasonable or a bad hack?

I have a big object: class BigObject{ public int Id {get;set;} public string FieldA {get;set;} // ... public string FieldZ {get;set;} } and a specialized, DTO-like object: class ...
0
votes
1answer
83 views

Is the regex syntax in .net 3.5 the same as the regex syntax in the latest version of .net framework in c#?

Is the regex syntax in .net 3.5 the same as the regex syntax in the latest version of .net framework in c#?
-1
votes
2answers
53 views

Appropriate Design Patterns [closed]

I have a list of objects which represent log entries like below. List<LogEntry> Entries; //Log Entries Read By A Log Reader The Log Entry Class contains following properties. public class ...
0
votes
1answer
84 views

Custom serializer or create base class which implements IXmlSerializable?

I am working on a project where I have very specific xml serialization specifications, that is: Some properties are elements, some are attributes Some properties are required others aren't Some ...
0
votes
0answers
55 views

Is there a better way to retrieve a ViewModel container starting from a Model?

I'm trying to figure out a more efficient method. To start, I have a viewmodel wrapping around a model. The model itself collectively becomes a tree. We'll call each model a Fragment: public class ...
5
votes
4answers
680 views

How to add a property to an object you can't change?

Let's say that I'm using a library and I would like to add a property that doesn't exist to an existing class. In this case, I'd like to add Color as a property of Fruit. namespace Library { ...