Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [c#]

C# is a multiparadigm, managed, garbage-collected object-oriented programming language created by Microsoft in parallel with the .NET platform

4
votes
1answer
2k views

Is ViewModel with more than one repository bad?

I'm working on a project with MVVM. Some ViewModels have more than one repository. Is ViewModels with more than one repository bad? Please provide with why it's good/bad.
6
votes
15answers
3k views

Why OOP is enforced in Java and C#? [closed]

In many other languages like C++ and Javascript, OOP is optional. Procedural code is ok. But in languages like Java and C#, OOP is somewhat enforced. Everything is to be a part of a class or an object....
2
votes
5answers
4k views

Conways Game of Life C#

Not sure if this is the correct place for this question or SO - mods please move if necessary. I am going to have a go at creating GoL over the weekend as a little test project : http://en.wikipedia....
16
votes
6answers
5k views

Convert from Procedural to Object Oriented Code

I have been reading Working Effectively with Legacy Code and Clean Code with the goal of learning strategies on how to begin cleaning up the existing code-base of a large ASP.NET webforms application. ...
7
votes
5answers
77k views

C# Multithreading Interview questions for a senior developer/designer position

I wonder what sort of interview questions were asked to a senior developer or technical consultant on multithreading. Kindly provide me some of the interview questions which were asked in the ...
1
vote
3answers
272 views

Addressing a variable in VB

Why doesn't Visual Basic.NET have the addressof operator like C#? In C#, one can int i = 123; int* addr = &i; But VB has no equivalent counter part. It seems like it should be important. ...
3
votes
3answers
1k views

Interop Best Practices: Should I use Static Class, or Normal Classes

I have a front end C# that needs to call a C++ back end. So interop is needed. I have an "interop layer", that converts the C# data structure into C++ structure, and do all the memory freeing grunt ...
5
votes
2answers
2k views

what is a proper way to register eventHandler

I was showing some of my code to a junior programer, and he asked me why am I registering functions for event handling like this: button1.Click += new RoutedEventHandler(button1_Click); and not like ...
10
votes
12answers
10k views

Is there a supported way to run .NET 4.0 applications natively on a Mac?

What, if any, are the Microsoft supported options for running C#/.NET 4.0 code natively on the Mac? Yes, I know about Mono, but among other things, it lags Microsoft. And Silverlight only works in a ...
45
votes
11answers
4k views

Which C# practices should be avoided in C++?

I'm currently teaching myself C++. I'm very proficient at C#, and was wondering which common practices in C# can lead to difficulties in C++, and what a C++ programmer should do instead.
14
votes
3answers
10k views

How do I set up MVP for a Winforms solution?

I have used MVP and MVC in the past, and I prefer MVP as it controls the flow of execution so much better in my opinion. I have created my infrastructure (datastore/repository classes) and use them ...
1
vote
5answers
371 views

Does this have a name? DRY overloading?

public int foo(int x) { int defaultValue = 0; return foo(x, defaultValue); } public int foo(int x, int y) { return x + y; }
6
votes
2answers
2k views

How would you TDD the functionality of getting the corresponding process of a running windows service?

Purpose Over the last year or more I've been learning unit testing via books I've read recently like The Art of Unit Testing, Working Effectively with Legacy Code, and others. I've also been using ...
13
votes
3answers
17k views

How to simulate events that cause exceptions to test try/catch blocks?

I understand how exceptions work and how to catch and handle them in C# but how can I simulate events that may cause an exception to ensure that it is caught correctly? For example, is it possible to ...
5
votes
11answers
5k views

Learning C, C++ and C# [duplicate]

I'm sure you guys are tired of this question but after wading through hours of similar posts and questions I've really not made any progress to my specific concerns. I was hoping you guys could shed ...
4
votes
6answers
535 views

Why are interfaces not casteable/ducktypeable?

One thing that always irked me (in C#) was that there's a hard dependency between an interface/abstract class and the implementing class and assembly. Meaning that that if two different assemblies ...
140
votes
7answers
282k views

Relationship between C#, .NET, ASP, ASP.NET etc [closed]

I'm really unclear on the difference between C#, C#.NET and the same for ASP and other '.NET' languages. From what I understand, .NET is a library/framework of... things. I think they're essentially ...
4
votes
3answers
780 views

How would you design an application with many target platforms and devices?

I'm in a very beginning of the design phase of an application that will have to run in the following platforms/devices: Desktop: Windows, Linux & Mac Mobile: Android, iPhone/iPad & Windows ...
15
votes
4answers
6k views

Is It “Wrong”/Bad Design To Put A Thread/Background Worker In A Class?

I have a class that will read from Excel (C# and .Net 4) and in that class I have a background worker that will load the data from Excel while the UI can remain responsive. My question is as follows: ...
10
votes
4answers
4k views

Number of Classes in a Namespace - Code Smell?

I have a C# library that's used by several executables. There's only a couple namespaces in the library, and I just noticed that one of the namespaces has quite a few classes in it. I've always ...
34
votes
6answers
25k views

Explicitly defining variable data types vs. using the keyword 'var'? [closed]

In C#, am I encouraged to use the all-purpose var keyword for every variable declaration? If yes, do I have to mention those special characters for literal values within the variable declaration like ...
0
votes
2answers
2k views

C# class architecture for REST services

I am integrating with a set of REST services exposed by our partner. The unit of integration is at the project level meaning that for each project created on our partners side of the fence they will ...
11
votes
9answers
526 views

Studies on code documentation productivity gains/losses

After much searching, I have failed to answer a basic question pertaining to an assumed known in the software development world: WHAT IS KNOWN: Enforcing a strict policy on adequate code ...
6
votes
2answers
5k views

Should I use a Class or Dictionary to Store Form Values

I am working on a C# .NET Application, where I have a Form with lots of controls. I need to perform computations depending on the values of the controls. Therefore, I need to pass the Form values to a ...
3
votes
1answer
170 views

Should I forward the a call to .Equals onto .Equals<T>?

So, I've got you bog standard c# object, overriding Equalsand implementing IEquatable public override int GetHashCode() { return _name.GetHashCode(); } public override bool ...
69
votes
7answers
74k views

When to use abstract classes instead of interfaces with extension methods in C#?

"Abstract class" and "interface" are similar concepts, with interface being the more abstract of the two. One differentiating factor is that abstract classes provide method implementations for derived ...
139
votes
8answers
142k views

How do you organize your projects? [closed]

Do you have any particular style of organizing projects? For example, currently I'm creating a project for a couple of schools here in Bolivia, this is how I organized it: TutoMentor (Solution) ...
18
votes
13answers
2k views

C# or .Net features to cut off assuming no backward compatibility needed? [closed]

Any product or framework evolves. Mainly it's done to catch up the needs of it's users, leverage new computing powers and simply make it better. Sometimes the primary design goal also changes with the ...
21
votes
16answers
27k views

How many lines of code can a C# developer produce per month? [closed]

An executive at my workplace asked me and my group of developers the question: How many lines of code can a C# developer produce per month? An old system was to be ported to C# and he would like ...
9
votes
12answers
4k views

Property-coalescing operator for C#

The null-coalescing operator in c# allows you to shorten the code if (_mywidget == null) return new Widget(); else return _mywidget; Down to: return _mywidget ?? new Widget(); I ...
3
votes
2answers
464 views

Best way to expose a data-oriented service

I'm currently tasked with writing a wcf service that, for now, will only used inside the company network, the problem is that I'm not sure how I should handle the operations it exposes. The software ...
5
votes
7answers
8k views

Getting started with C# and Databases [closed]

I want to start using Databases in my C# Applications, unfortunately there appears to be lots of different ways of going about this. Which is the 'best' way from a learning perspective? (IE: What is ...
25
votes
5answers
12k views

Moving from Winforms to WPF [closed]

I am a long time experienced Windows Forms developer, but now it's time to move to WPF because a new WPF project is comming soon to me and I have only a short lead time to prepare myself to learn WPF. ...
22
votes
11answers
7k views

How does one meaningfully measure maintainability?

Context: I'm an enterprise developer in an all-MS shop. Can anyone recommend a good way of objectively measuring maintainability of a piece of code or an application? Why maintainability: I'm tired ...
12
votes
6answers
2k views

Learning C# and stuck in a rut [closed]

I've been learning C#/.NET 4.0 for about 2/3 months, it's my first serious programming language (I've looked at PHP, HTML, CSS, JavaScript, and VBA before but never massively in depth) and I'm ...
11
votes
4answers
7k views

What is platform independence? Are cross-platform and 'platform independence' same?

What is the platform independence really mean? What are the criterion to call a language platform independent ? Are cross-platform and 'platform independence' same? (This may be a question for self ...
5
votes
4answers
16k views

C# Classes instance members vs. enum

What is the difference between private variables in a clsClass type and using enumeration enum to instantiate the variable. This question arose when I was looking at some C# Class code for serial ...
8
votes
7answers
7k views

From non programmer to “professional” freelance programmer [closed]

I am 15 year old student looking to buy his first car and thought I could earn some extra money by learning to program since I like messing around with the computer all the time. I have been reading ...
4
votes
1answer
2k views

Why has the PowerCollections C# library recently declined in popularity? [closed]

I just looked at the statistics for the PowerCollections C# library and noticed a sharp decrease in quantity of downloads. What may be the cause? Is there something better I should be using?
0
votes
1answer
760 views

Windows Phone 7 dev: C# or silverlight for a simple app?

I'm about to hire a programmer to develop Windows Phone 7 apps. The current app that shall be developed is quite simple. The app will download content from a Web-API. There are two lists to ...
4
votes
1answer
1k views

Dependency analysis from C# code through to database tables/columns [closed]

I'm looking for a tool to do system wide dependency analysis in C# code and SQL Server databases. It's looking like the only tool available that does this might be CAST (CAST software), which is ...
3
votes
1answer
289 views

How to define template directives (from an API perspective)?

Preface I'm writing a template language (don't bother trying to talk me out of it), and in it, there are two kinds of user-extensible nodes. TemplateTags and TemplateDirectives. A TemplateTag ...
14
votes
16answers
1k views

Should a c# dev switch to VB.net when the team language base is mixed?

I recently joined a new development team where the language preferences are mixed on the .net platform. Dev 1: Knows VB.net, does not know c# Dev 2: Knows VB.net, does not know c# Dev 3: Knows c# and ...
8
votes
4answers
6k views

Is nesting types considered bad practice?

As noted by the title, is nesting types (e.g. enumerated types or structures in a class) considered bad practice or not? When you run Code Analysis in Visual Studio it returns the following message ...
3
votes
2answers
641 views

Is is common to use the command pattern for property get/sets?

Suppose I have a controller class with a bunch of properties. Each time a property is changed, I would like to update the model. Now also suppose that I use the command pattern to perform model ...
1
vote
3answers
3k views

Why is C# ASP.NET generally not regarded as a rapid web development framework?

The terms rapid web development gets associated with Python/Django and ROR. Why is this not the case with C# ASP.NET?
10
votes
3answers
2k views

Balancing dependency injection with public API design

I've been contemplating how to balance testable design using dependency injection with providing simple fixed public API. My dilemma is: people would want to do something like var server = new Server()...
5
votes
2answers
8k views

What are the best practices for exception handling in n-tier applications?

What are the best practices for exception handling in n-tier applications? The application is a fat client based on MVVM pattern with .NET framework.
46
votes
5answers
17k views

As a C# developer, would you learn Java to develop for Android or use MonoDroid instead? [closed]

I'd consider myself pretty well versed in C#. It's my language of choice at the moment, and it's where basically all my professional experience lies. Still, I'm puzzled by the existence of the ...
18
votes
4answers
30k views

Delphi vs C# for GUI programming [closed]

I'm coming from PHP and Python background with little knowledge of C, I have done many web based application now I'm thinking of Desktop application for windows platform. A friend told me to go for ...