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

7
votes
1answer
1k views

What is a good strategy for testing UserControls?

A UserControl cannot be dragged-dropped onto a winform. Instead, I must compile the assembly add it to my toolbox, then I can drag it onto a Form. Doing this toolbox approach just to test out a ...
1
vote
1answer
608 views

Where should I locate the cache in a WCF service?

I am going to build a Windows Communication Foundation (WCF) service using Microsoft Enterprise Library for caching. I am wondering whether or not I should put the cache in the service layer. If I do ...
6
votes
3answers
2k views

When calling a method should we use base.methodname and this.methodname?

In C#, with an inherited class set -- when calling a method should we use keywords 'base.methodname and this.methodname'... irrespective of whether it is a overridden method or not? The code is ...
3
votes
5answers
617 views

Using XML field Vs. creating a table for unstable organization

I am in the middle of design an application to issue and store invoices for an organization. The problem is the organization is not stable at all. There are many types of invoices and they may ...
5
votes
1answer
1k views

Passing data between concrete states?

I have a state machine pattern implementation that's pretty straightforward, but I've got a design problem I don't know an elegant solution to. Here's some partly pseudo code to illustrate. class ...
20
votes
9answers
2k views

Adding complexity to remove duplicate code

I have several classes that all inherit from a generic base class. The base class contains a collection of several objects of type T. Each child class needs to be able to calculate interpolated ...
5
votes
2answers
907 views

Create Primary Interop Assemblies or generate them?

I've never seen this question answered definitively: If you are maintaining a COM DLL that can be used by a .NET program, is it best to: Import the COM DLL into each project, which generates an ...
27
votes
8answers
14k views

Private variable vs property?

When setting a value to a variable inside of a class most of the time we are presented with two options: private string myValue; public string MyValue { get { return myValue; } set { myValue = ...
30
votes
8answers
2k views

S.O.L.I.D., avoiding anemic domains, dependency injection?

Although this could be a programming language agnostic question, I'm interested in answers targeting the .NET ecosystem. This is the scenario: suppose we need to develop a simple console application ...
20
votes
12answers
16k views

What are the practical uses of Windows Services?

I am new to working with Windows Services. Although I have learnt to create Windows Services in VS2010 I would like to know some practical ways in which windows services could be used? I tried ...
26
votes
4answers
6k views

Is having public constants “bad”?

Is this: public MyClass { public const string SomeString = "SomeValue"; } worse than this: public MyClass { public static string SomeString { get{ return "SomeValue";}} } Both can be ...
1
vote
1answer
612 views

Windows GUIs: How Long Will 'Deprecated' APIs Last? [closed]

Note I said 'deprecated' and not 'abstracted'. Back in the days of the MFC, the WinAPI wasn't deprecated because, from what I've read, the MFC merely abstracted the WinAPI. There's a difference, for a ...
12
votes
1answer
288 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 ...
6
votes
4answers
798 views

Object-oriented design question

I am using a class through a dll to which I do not have direct control. So in effect, I am only a client of this class. The class represents a form that can be printed, sent to clients and tracked ...
2
votes
2answers
1k views

Is it possible to integrate UDP file transfer into a .NET web application?

Background I have recently been tasked with designing a rebuild of an existing .NET web application that currently uses a third-party company to handle large file transfers (as big as 50Gb). ...
5
votes
6answers
13k views

string.format with variables vs inline variables

What are the pros/cons (if any) to using string output; int i = 10; output = string.Format("the int is {0}", i); versus string output; int i = 10; output = "the int is " + i; I have always ...
0
votes
2answers
356 views

How to solve a fundamental cloud data storage dispute?

I'm working for a company that has recently hired me to create a new version of their existing software, which is now over 12 years old. The new software is a complete re-write of the old and they ...
3
votes
3answers
6k views

Should one bind data with Eval on aspx or override ItemDataBound in code-behind?

For data bound controls (Repeater, ListView, GridView, etc.), what's the preferred way of binding data? I've seen it where people use Eval() directly on the aspx/ascx inside the data bound control to ...
14
votes
5answers
4k views

How to structure unit tests for a GUI app using C# and NUnit

I've been asked to do a small side-project to supply a simple application to one of our customers. Normally I would be working on back-end code where I have all of my testing needs figured out, and ...
4
votes
3answers
3k views

Is querying KeyValue Pairs efficient compared to two-property objects?

I'm working on a webservice and I'm returning JSON. However, I'm returning a List<KeyValuePair<string, int>>, since that's all I'm really ever going to be dealing with (property => value) ...
4
votes
3answers
2k views

How to use a MessageBox using the MVVM pattern?

I am implementing a UI application using the MVVM design-pattern. The thing is, sometimes when you detect that something is wrong with data that was inputted by the user, you'd like to notify him ...
7
votes
4answers
24k views

Best practice to query data from MS SQL Server in C Sharp?

What is the best way to query data from a MS SQL Server in C Sharp? I know that it is not good practice to have an SQL query in the code. Is the best way to create a stored procedure and call it ...
32
votes
2answers
7k views

Why is 'void' not allowed as a generic type in C#

What were the design decisions that argued in favour of void not being constructable and not being allowed as a generic type? After all it is just a special empty struct and would have avoided the ...
5
votes
5answers
2k views

When and why should one create classes at runtime?

I have read many articles on the creation of dynamic types and classes at run time. For example, the TypeBuilder class in C# lets one create dynamic types. Python has this type function by which one ...
13
votes
5answers
8k views

Load testing : how to generate per second requests?

I have a server component which runs over Zeroc-ICE. When I wanted to load test it, I thought that using parallel library to create multiple requests would do it. But it dint end up that way. Using ...
6
votes
4answers
1k views

What is the best way to access multiple child properties?

I have a situation where I have to access several "sub-properties" of an object and find it quite appalling to write such code. I was wondering how best to deal with this situation: void Main() { ...
40
votes
8answers
3k views

Can modern OO languages compete with C++'s array store performance?

I just noticed that every modern OO programming language that I am at least somewhat familiar with (which is basically just Java, C# and D) allows covariant arrays. That is, a string array is an ...
32
votes
4answers
3k views

What is the point of the string.Empty property

Why was the property string foo = string.Empty included in the BCL? It seems more verbose and no clearer than just using an empty string (string foo = "")
7
votes
2answers
528 views

Are there any opensource APIs that help analyze code?

As an example, let's say that I need to check for a certain usage of C# code and warn the user that that is a bad pratice. There are multiple usages that I want to detect, such as: Resource not ...
1
vote
2answers
203 views

Need help with deciding elements for icon creating application

I'm trying to practice programing by creating a simple application which, I think, I can manage to do in .Net C# in VisualStudio 2010. I'm working on simple application which will let me to create ...
3
votes
2answers
853 views

thick client migration to web based application

This query is related to application design the technology that I should consider during migration. The Scenario: I have a C#.net Winform application which communicates with a device. One of the main ...
4
votes
2answers
1k views

MVVM Reporting App Approach ? Data Access Layer?

I'm trying to follow the MVVM pattern in a reporting / statistics application that I'm making in C# / WPF. I have made many model classes to hold properties as a starting point. Some of these models ...
4
votes
2answers
1k views

How should I handle application settings in C#? [closed]

I am pretty new to the .NET framework so please bare with me. I am writing a time counter in C#, that counts the amount of time that has elapsed since a particular moment in time. That moment in time, ...
2
votes
2answers
364 views

Would like to add features to Text Editor - which editor to choose? [closed]

I would like to add some new features to a text editor. The main requirements I have are: Should be a programmer's editor I would like to target C# editor features to start with (since I work in ...
1
vote
1answer
302 views

Is it ok to call external services or database inside the entity

I have "logic engine" which executes set of user configured steps. These steps are saved in the database as "Step" entities. The engine gets the first step and then executes steps until there are no ...
0
votes
2answers
141 views

Suggestions for search methodology requested

I am throwing this question out to the 'greater creativity' for some suggestions on search methodology that might solve this problem. I have come up with a somewhat contrived example to attempt to ...
6
votes
6answers
971 views

Organizing Class Members in Regards to Access Modifier

If we look at typical implementation of a Class, we usually see the private members defined at the beginning and public( mostly functions and Accessors) defined towards the bottom. Now, is this a ...
9
votes
6answers
2k views

How to verify/prove orthogonality of a programming language?

I know the concept of orthogonality, but from a programming language point of view, is there a way to verify/prove it? For instance in C#, one can use public or static for a method signature. You can ...
14
votes
9answers
7k views

C++ for C# Developers

I know C# pretty well (self-taught, sadly) and need to do some C++ programming for a Windows application. I have been able to find a ton of information for C++ developers learning C# but haven't been ...
6
votes
2answers
536 views

How to structure this program?

I am struggling with the best way to structure a program that I am writing because the method I currently have feels very clunky and each part depends a lot on the others. This is what the program ...
3
votes
1answer
495 views

Is there any point in distributing separate .NET 3.5 and 4.0 assemblies?

I want to distribute a .NET library that is .NET 3.5 compliant. The library holds references only to external managed libraries that are targeted against .NET 3.5 client profile or lower. Is there any ...
3
votes
3answers
378 views

What's a RESTful url for a linked item?

This is going to be a web service that returns a JSON object. Currently, I'm using C# technology and simply using ASP.Net MVC to create the calls. This is not a web page, so SEO is not a concern. ...
2
votes
1answer
462 views

How should I organize the Presenters/Views for model view presenter?

We have several hundred ASPX files (could be more than that, into the thousands, I haven't actually counted) that currently use no architecture and have all the logic/data access in code-behind files. ...
1
vote
1answer
292 views

Accessing the same service more than twice in the nick of time

I have an application that will access interface service A which is to run from windows startup. This service is used by program B and my application functions on B's presence after getting a pointer ...
2
votes
4answers
305 views

Do more object declarations affect the program?

I am programming in Windows Forms and MySQL. If I declare this in the program, I can use the connection and command objects in the whole .cs page: MySqlConnection connection = null; MySqlCommand ...
1
vote
2answers
864 views

Implications of handles between forms

I was developing a WindowsForm application in C#, with 2 forms. Regardless of what they both did specifically I needed to access values in form2 and send them to form1 and vice versa. For this to ...
8
votes
2answers
4k views

Looking for a distributed locking pattern

I need to come up with a custom recursive object locking mechanism\pattern for a distributed system in C#. Essentially, I have a multi-node system. Each node has exclusive write permissions over ...
4
votes
4answers
3k views

How to treat “The field is never used” warnings?

Warning 1 The field 'MCS_SPS_School.Fees.DiscountAmt.rtvalue' is assigned but its value is never used G:\Jagadeeswaran\Nov 17\MCS-SPS School\MCS-SPS School\Fees\DiscountAmt.cs Warning 2 ...
8
votes
4answers
2k views

What are the consequences of having unnecessary references and usings?

I'm a bit of a neat freak and tend to keep my projects by cleaning references and usings in each class to keep only what's actually used. What other argument could I make (besides calming my OCD ...
6
votes
5answers
2k views

Why is there both a short-circuit OR as well as unshort-circuited variation of that operator in C#?

Periodically, I wonder about this: The short-circuit OR would always return the same value that the unshort-circuited OR operator would? I expect that the short-circuit OR would always evaluate ...