Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
C# is a multi-paradigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform. Use this tag for questions related to C#. In case a specific version of the framework is used, you could also include that tag; for instance .net-2.0.
13
votes
Accepted
Scanning a .cs file or a directory
In my opinion, the easiest way would be to embrace exceptions. DirectoryNotFoundException and FileNotFoundException are there for a reason, and actually even calling .Exists might not save you from th …
5
votes
Accepted
Is there a better way to do this linq sort?
You're correct, it can be costly.
You can just expand the lambda expression:
Assets.OrderBy(a => {
var item = a.GalleryItems != null
? a.GalleryItems.FirstOrDefault(gi => gi.Prod …
6
votes
Accepted
Returning a list of income for a month
I'm going to elaborate on what I mentioned in comments.
Assuming you're using LINQ to Entities, this line:
var invoices =
db.SellInvoices
.Where(invoice => invoice.Date >= startDat …
7
votes
Bread formula object
Here's my humble opinion, it generally looks OK, here are some basic tips:
Use generic collections if you can, List<Ingredient> instead of ArrayList, you won't have to cast it later on
You can use L …
6
votes
2
answers
6k
views
Option type in C# and implicit conversions
I have decided to create a simple Option type for C#. I have essentially based it on the
Scala's Option.
It was mostly a fun exercise, but it might come in handy at work or any other project, even th …
3
votes
Consuming an ASP.NET Web API call in an MVC controller
All the controlers are regular classes with methods.
Assuming your API controller StudentDashboard has a Get(string name) verb method, you can do this:
public ActionResult Index() //This view is str …
0
votes
Optimizing LINQ routines
The main thing I'd try hard to get rid of is the loop. Calling a DB in a loop is rarely a good idea.
First option might be to try to do an equivalent of IN query:
var ids = items.Select(x => x.confi …