1,141 questions
1126
votes
19
answers
1.2m
views
Creating a byte array from a stream
What is the prefered method for creating a byte array from an input stream?
Here is my current solution with .NET 3.5.
Stream s;
byte[] b;
using (BinaryReader br = new BinaryReader(s))
{
b = ...
498
votes
13
answers
242k
views
What is the difference between IQueryable<T> and IEnumerable<T>?
What is the difference between IQueryable<T> and IEnumerable<T>?
See also What's the difference between IQueryable and IEnumerable that overlaps with this question.
1154
votes
22
answers
1.2m
views
LINQ query on a DataTable
I'm trying to perform a LINQ query on a DataTable object and bizarrely I am finding that performing such queries on DataTables is not straightforward. For example:
var results = from myRow in ...
751
votes
11
answers
287k
views
Which method performs better: .Any() vs .Count() > 0?
In the System.Linq namespace, we can now extend our IEnumerable's to have the Any() and Count() extension methods.
I was told recently that if I want to check that a collection contains one or more ...
85
votes
12
answers
110k
views
Will the IE9 WebBrowser Control Support all of IE9's features, including SVG?
I recently upgraded to IE9-beta. Now, In my .Net (3.5) WinForm application I want to use WebBrowser control.
So my question is, whether the WebBrowser control will exhibit all properties and ...
493
votes
13
answers
476k
views
WCF - How to Increase Message Size Quota
I have a WCF Service which returns 1000 records from database to the client. I have an ASP.NET WCF client (I have added service reference in asp.net web application project to consume WCF).
I get ...
225
votes
10
answers
329k
views
Creating a DateTime in a specific Time Zone in c#
I'm trying to create a unit test to test the case for when the timezone changes on a machine because it has been incorrectly set and then corrected.
In the test I need to be able to create DateTime ...
58
votes
14
answers
54k
views
How can I convert an integer into its verbal representation?
Is there a library or a class/function that I can use to convert an integer to its verbal representation?
Example input:
4,567,788`
Example output:
Four million, Five hundred sixty-seven thousand, ...
258
votes
10
answers
169k
views
Why Response.Redirect causes System.Threading.ThreadAbortException?
When I use Response.Redirect(...) to redirect my form to a new page I get the error:
A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll
An ...
87
votes
10
answers
83k
views
'Contains()' workaround using Linq to Entities?
I'm trying to create a query which uses a list of ids in the where clause, using the Silverlight ADO.Net Data Services client api (and therefore Linq To Entities). Does anyone know of a workaround to ...
754
votes
12
answers
681k
views
Use LINQ to get items in one List<>, that are not in another List<>
I would assume there's a simple LINQ query to do this, I'm just not exactly sure how.
Given this piece of code:
class Program
{
static void Main(string[] args)
{
List<Person> ...
131
votes
7
answers
64k
views
Conditional compilation and framework targets
There are a few minor places where code for my project may be able to be drastically improved if the target framework were a newer version. I'd like to be able to better leverage conditional ...
389
votes
35
answers
406k
views
Could not find default endpoint element
I've added a proxy to a webservice to a VS2008/.NET 3.5 solution. When constructing the client .NET throws this error:
Could not find default endpoint element that references contract '...
121
votes
16
answers
98k
views
Wait until file is unlocked in .NET
What's the simplest way of blocking a thread until a file has been unlocked and is accessible for reading and renaming? For example, is there a WaitOnFile() somewhere in the .NET Framework?
I have a ...
73
votes
11
answers
164k
views
How to detect installed version of MS-Office?
Does anyone know what would be the best way to detect which version of Office is installed? Plus, if there are multiple versions of Office installed, I'd like to know what versions they are. A bonus ...