Skip to main content

Questions tagged [.net]

The .NET Framework is a software framework for Microsoft Windows operating systems. It includes an implementation of the Base Class Library, Common Language Runtime, and Dynamic Language Runtime. It supports many programming languages, including C#, VB.NET, F# and C++.

Filter by
Sorted by
Tagged with
170 votes
10 answers

Mono is frequently used to say "Yes, .NET is cross-platform". How valid is that claim? [closed]

In What would you choose for your project between .NET and Java at this point in time? I say that I would consider the "Will you always deploy to Windows?" the single most important technical decision ...
user avatar
159 votes
6 answers

SOLID Principles and code structure

At a recent job interview, I couldn't answer a question about SOLID -- beyond providing the basic meaning of the various principles. It really bugs me. I have done a couple of days worth of digging ...
S-Unit's user avatar
  • 1,397
158 votes
8 answers

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) ...
user avatar
150 votes
8 answers

Are bad programming practices typical within the software industry? [closed]

I just started my first job as a software developer over a month ago. Everything I have learned about OOP, SOLID, DRY, YAGNI, design patterns, SRP, etc. can be thrown out the window. They use C# .NET ...
Grim's user avatar
  • 903
149 votes
7 answers

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 ...
Megan Walker's user avatar
  • 2,026
124 votes
12 answers

Effective Strategies for Localization in .NET [closed]

I am developing the UI for a .NET MVC application that will require international localization of all content in the near future. I am very familiar with .NET in general but have never had a project ...
smartcaveman's user avatar
  • 1,522
96 votes
8 answers

Return magic value, throw exception or return false on failure?

I sometimes end up having to write a method or property for a class library for which it is not exceptional to have no real answer, but a failure. Something cannot be determined, is not available, not ...
Daniel A.A. Pelsmaeker's user avatar
82 votes
6 answers

When to go Fluent in C#?

In many respects I really like the idea of Fluent interfaces, but with all of the modern features of C# (initializers, lambdas, named parameters) I find myself thinking, "is it worth it?", and "Is ...
Andrew Hanlon's user avatar
64 votes
13 answers

My boss has a bad case of "Not Invented Here" [closed]

My department specializes in converting customer data into our database schema so that they can use our software. Right now, we have C# applications that take an IDataReader (99% of the time it is a ...
Scott Chamberlain's user avatar
64 votes
17 answers

Why use an OO approach instead of a giant "switch" statement?

I am working in a .Net, C# shop and I have a coworker that keeps insisting that we should use giant Switch statements in our code with lots of "Cases" rather than more object oriented approaches. His ...
James P. Wright's user avatar
62 votes
6 answers

When to use weak references in .Net?

I have not personally come across a situation where I've needed to use WeakReference type in .Net, but the popular belief seems to be that it should be used in caches. Dr Jon Harrop gave a very good ...
theburningmonk's user avatar
60 votes
11 answers

Why is the use of abstractions (such as LINQ) so taboo? [closed]

I am an independent contractor and, as such, I interview 3-4 times a year for new gigs. I am in the midst of that cycle now and got turned down for an opportunity even though I felt like the ...
Matt Cashatt's user avatar
  • 3,315
59 votes
7 answers

.NET Properties - Use Private Set or ReadOnly Property?

In what situation should I use a Private Set on a property versus making it a ReadOnly property? Take into consideration the two very simplistic examples below. First example: Public Class Person ...
tgxiii's user avatar
  • 693
55 votes
2 answers

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 ...
user avatar
54 votes
5 answers

How to deal with fear of taking dependencies

The team I'm in creates components that can be used by the company's partners to integrate with our platform. As such, I agree we should take extreme care when introducing (third-party) dependencies. ...
robinwit's user avatar
  • 650
54 votes
3 answers

Best practices for logging and tracing in .NET

I've been reading a lot about tracing and logging, trying to find some golden rule for best practices in the matter, but there isn't any. People say that good programmers produce good tracing, but put ...
Levidad's user avatar
  • 798
52 votes
11 answers

I don't understand how TDD helps me get a good design if I need a design to start testing it

I'm trying to wrap my head around TDD, specifically the development part. I've looked at some books, but the ones I found mainly tackle the testing part - the History of NUnit, why testing is good, ...
Michael Stum's user avatar
  • 1,778
50 votes
2 answers

Why does the .Net world seem to embrace magic strings instead of staticly typed alternatives?

So, I work in .Net. I make open source projects in .Net. One of my biggest problems with it isn't necessariyl with .Net, but with the community and frameworks around it. It seems everywhere that ...
Earlz's user avatar
  • 22.9k
49 votes
5 answers

When and why to use Nested Classes?

Using Object Oriented Programming we have the power to create a class inside a class (a nested class), but I have never created a nested class in my 4 years of coding experience. What are nested ...
mayur rathi's user avatar
48 votes
5 answers

async+await == sync?

Stumbled upon this post that talks about making async web requests. Now simplicity aside, if in real world, all you do is make an async request and wait for it in the very next line, isn't that the ...
Mrchief's user avatar
  • 631
46 votes
5 answers

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 ...
Dan Tao's user avatar
  • 1,201
46 votes
8 answers

Why doesn't "object reference not set to an instance of an object" tell us which object?

We're launching a system, and we sometimes get the famous exception NullReferenceException with the message Object reference not set to an instance of an object. However, in a method where we have ...
Saeed Neamati's user avatar
43 votes
13 answers

Is it unreasonable to expect Any() *not* to throw a null reference exception?

When you create an extension method you can, of course, call it on null.But, unlike an instance method call, calling it on null doesn't have to throw a NullReferenceException -> you have to check and ...
thisextendsthat's user avatar
42 votes
5 answers

Am I wrong in thinking that needing something like AutoMapper is an indication of poor design?

Automapper is an "object-object mapper" for .Net, which means copying objects from a class into another class that represents the same thing. Why is this ever useful? Is the duplication of classes ...
static_rtti's user avatar
40 votes
8 answers

Inverting an IF statement

So I've been programming for a few years now and recently have started using ReSharper more. One thing that ReSharper always suggests to me is to "invert 'if' statement to reduce nesting". Let's say ...
Barry Franklin's user avatar
39 votes
4 answers

Why would anyone invest time in Microsoft "Roslyn"?

I have just been reading through some of the white papers & examples from Microsoft "Roslyn" and the concept seems very interesting. From what I can tell, it opens up the black box that is the ...
Richard Hooper's user avatar
37 votes
8 answers

Why do .Net books talk about stack vs heap memory allocation?

It seems like every .net book talks about value types vs reference types and makes it a point to (often incorrectly) state where each type is stored - the heap or the stack. Usually it's in the first ...
Greg's user avatar
  • 795
36 votes
8 answers

Is Linq having a mind-numbing effect on .NET programmers?

A lot of us started seeing this phenomenon with jQuery about a year ago when people started asking how to do absolutely insane things like retrieve the query string with jQuery. The difference ...
Aaronaught's user avatar
  • 44.4k
36 votes
3 answers

Why is there no generic implementation of OrderedDictionary in .net?

Why did Microsoft not provide generic implementation of OrderedDictionary? There are a few custom implementations I've seen, including:
nonot1's user avatar
  • 711
35 votes
8 answers

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 ...
David Robert Jones's user avatar
34 votes
13 answers

Career advice: stay with PHP or start a new career in something else ( .Net?) [closed]

I'm planning on moving to NY in 6-12 months tops, so I'm forced to find a new job. When I'm planing to start my life in another city it's also probably a good time to think about career changes. I've ...
Christian P's user avatar
  • 1,954
34 votes
6 answers

Why would you ever 'await' a method, and then immediately interrogate its return value?

In this MSDN article, the following example code is provided (slightly edited for brevity): public async Task<ActionResult> Details(int? id) { if (id == null) { return new ...
Robert Harvey's user avatar
34 votes
4 answers

Why after each restart, my local .NET sites take time to load for the first time? [closed]

I'm developing sites based on .NET platform. I usually deploy these sites on my local IIS, so that I can test them and see their functionality before going live. However, each time I restart windows, ...
Saeed Neamati's user avatar
33 votes
4 answers

Why does F# have an interactive mode but not C#?

F# comes out of the box with an interactive REPL. C# has nothing of the sort and is in fact kinda difficult to play around without setting up a full project (though LINQpad works and its also possible ...
George Mauer's user avatar
  • 2,012
33 votes
3 answers

Is it bad practice to use public fields? [duplicate]

Possible Duplicate: When are Getters and Setters Justified Why are public and private accessors considered good practice? In my time as developer I learned that properties can be very useful. I ...
Jonathan Egerton's user avatar
32 votes
7 answers

How to treat unhandled exceptions? (Terminate the application vs. Keep it alive)

What is best practice when a unhandled exceptions occurs in a desktop application? I was thinking about to show a message to the user, so that he can contact support. I would recommend to the user to ...
Jonas Benz's user avatar
32 votes
7 answers

Dictionary vs List

So I ran into a Dictionary<int, int> today at work. This just seemed weird to me because I would have probably just used a List<int> instead. Is there a difference and would there be a use ...
Stephen__T's user avatar
32 votes
11 answers

Declaring interface in the same file as the base class, is it a good practice?

To be interchangable and testable, normally services with logic needs to have interface, e.g. public class FooService: IFooService { ... } Design-wise, I agree with this, but one of the things that ...
Louis Rhys's user avatar
  • 6,142
31 votes
13 answers

What are the criteria for evaluating an ORM for.NET? [closed]

I'm looking at evaluating ORMs. I've used SubSonic, Linq-to-SQL and Entity Framework. I've got a team of developers ranging from juniors to seniors. What are the criterias for evaluating an ORM ...
Nickz's user avatar
  • 1,430
31 votes
3 answers

Reflection: Is using reflection still "bad" or "slow"? What has changed with reflection since 2002?

I've noticed when dealing with Expressions or Expression Trees I'm using reflection a lot to set and get values in properties and what have you. It has occurred to me that the use of reflection seems ...
blesh's user avatar
  • 919
31 votes
4 answers

Why do we need the async keyword?

I just started playing around with async/await in .Net 4.5. One thing I'm initially curious about, why is the async keyword necessary? The explanation I read was that it is a marker so the compiler ...
ConditionRacer's user avatar
30 votes
9 answers

Why was Scala not implemented with C or C++

Does anybody know why was Scala implemented in Java and .NET instead of C or C++? Most languages are implemented with Cor C++ [i.e Erlang, Python, PHP, Ruby, Perl]. What are the advantages for Scala ...
Joshua Partogi's user avatar
29 votes
6 answers

Is it worth even checking to see if Guid.NewGuid() is Guid.Empty?

In one of the projects I'm working on the following pattern is seen on a fairly regular basis: var guid = Guid.NewGuid().ToString(); while (guid == Guid.Empty.ToString()) { guid = Guid.NewGuid()....
rjzii's user avatar
  • 11.3k
29 votes
5 answers

How to properly structure a project in winform?

A while ago I started to create a winform application and at that time it was small and I did not give any thought of how to structure the project. Since then I added additional features as I needed ...
user850010's user avatar
29 votes
5 answers

Alternatives to the repository pattern for encapsulating ORM logic?

I've just had to switch out an ORM and it was a relatively daunting task, because the query logic was leaking everywhere. If i'd ever had to develop a new application, my personal preference would be ...
Dante's user avatar
  • 1,539
28 votes
3 answers

In C#, why are variables declared inside a try block limited in scope?

I want to add error handling to: var firstVariable = 1; var secondVariable = firstVariable; The below won't compile: try { var firstVariable = 1; } catch {} try { var secondVariable = ...
JᴀʏMᴇᴇ's user avatar
28 votes
5 answers

Why use the discard variable in C#?

When coding resharper recommends that if you're to discard or ignore the return of a method, that you use this syntax: _ = TheMethodICouldCareLessAboutTheReturnValue(); I know you could just call it ...
MadScribbler's user avatar
28 votes
3 answers

C# 8 non-nullable references and the Try pattern

There is a pattern in C# classes exemplified by Dictionary.TryGetValue and int.TryParse: a method that returns a boolean indicating success of an operation and an out parameter containing the actual ...
Sebastian Redl's user avatar
28 votes
3 answers

Why should I use List<T> over IEnumerable<T>?

In my MVC4 web application I use IEnumerables, trying to follow the mantra to program to the interface, not the implementation. Return IEnumerable(Of Student) vs Return New List(Of Student) ...
Rowan Freeman's user avatar
27 votes
15 answers

How do I convince my team to use smaller classes/methods?

Disclaimer: I'm a newcomer (this is my third day of work), and most of my teammates are more experienced than me. When I look at our code, I see some code smells and bad engineering practices, like ...
Deltax76's user avatar
  • 1,041

2 3 4 5