Consider the IEnumerable extension methods SingleOrDefault() and FirstOrDefault()
MSDN documents that SingleOrDefault:
Returns the only element of a sequence, or a default value if the sequence is empty; this method throws an exception if there is more than one element in the sequence.
whereas FirstOrDefault from MSDN (presumably ...
If I have 10 different objects serialized/deserialized using a Generic T class that uses the XmlSerializer internally, how can I know which type to use when deserializing it?
MyXmlSerializer.Deserialize<MyObject> ( ... )
How can I know MyObject? All I have is a stringstream.
...
I have a slightly unusual situation where I'm needing to maintain CLIENT tcp connections to another server for thousands of mobile users on my servers (basically the mobile devices connect to my middle tier server when they are able to, which maintains a more stable connection to the 3rd party server for the mobile devices).
Anyways, I'...
This is a rephrase of an earlier question, which got chopped down badly by the community. Fair enough, it might have been too argumentative.
Since I'm really interested in what people here think about this, hopefully this more specific question will be accepted.
Name a benefit which the Win32 API will still have over .NET in 3-5 years...
I know how to launch the "ASP.NET Web Site Administration Tool" from Visual Studio and modify the security settings in the web.config of my Web project.
However, can I use the same tool to configure a remote website (hosted in some server), without Visual Studio (just as a website?)
If it's not possible. Is there a control that I can a...
Hi,
I'm creating a multi-tabbed .NET application that allows the user to dynamically add and remove tabs at runtime. When a new tab is added, a control is added to it (as a child), in which the contents can be edited (eg. a text box). The user can perform tasks on the currently visible text box using a toolbar/menu bar.
To better expla...
Hi
I don't know too much about streams in C#. Right now I have a stream that I put into a stream reader and read it. Later on in some other method I need to read the stream(same stream object) but this time I get this error
System.ArgumentException was unhandled by user code
Message="Stream was not readable."
Source="mscorlib"
St...
The algorithm I need to come up with is one that computes all the factors for a user-entered number, for example the user would enter "50" and the program would display all the factors of fifty which are: 1, 2, 5, 10, 25, 50.
This program would need to work for all positive integer values.
Would anybody be willing to show me how to ...
Anyone know of a library/framework like httplib2 (python) http://code.google.com/p/httplib2/ for .NET?
It wouldn't be difficult to duplicate it, but would be a waste if it already existed some where.
Thanks.
...
I have a do while loop that reads a buffer from a NetworkStream object
the while condition is networkStream.CanRead so as long as it can read it should continue reading from the buffer. Only problem is when I read from the buffer and convert to string, there is nothing in it . i.e. its empty.
Why would that happen?
This is an ASP.net (...
I need to detect drag and drop operations in an external application, is it possible? I thought of writing a hook to detect these operations. Can anybody point me in the right direction as far as which messages or api functions I could attempt to hook to detect the Drag & Drop events? I want to do this in C#.
Thanks in advance.
...
I'm trying to determine the currently selected portion of the date (or time) editor. I need to to provide custom action when the navigation keys on PDA are use. In particular i want the focus to go to the next control when pressing Right button and having the last portion of the date selected (e.g year). Default behavior is cycling throu...
I have a ServiceContract describing a method used in a WCF service. The method has a WebGet attribute which defines a UriTemplate and ResponseFormat.
I want to reuse a single method and have multiple WebGet attributes with different UriTemplates and different ResponseFormats. Basically I'm hoping to avoid having multiple methods just...
Hello,
I have a complex object graph to represent operation scheduling.
At one point, I have to serialize the whole graph to the web UI (via XML/JSON) to let user modify the schedule using a Javascript based gantt chart component.
After the user finished editing, the state of the graph in the Java/server layer have to be synchronized wi...
I have a DataGridView in virtual mode that gets continuously updated by inserting rows at the top of the grid, so that rows appear to "flow down".
When the grid is not updated, cell selection behaviour is as expected: mouse drag selection results in contiguous rectangular selection region.
When the grid gets continuous updates, the sel...
Unfortunately, there is no Semaphore in System.Threading when using the .NET Compact Framework.
I'm not sure why that is, does anyone have an idea?
After googling I've found a bunch of people giving their own implementations, but none of them really worked great... or at all!
So I've come to ask the experts...
Does anyone have a good...
Hi
I am not sure what I am doing wrong. I am trying to use the asp.net regex.replace but it keeps replacing the wrong item.
I have 2 replaces. The first one does what I want it to it replaces what I want. The next replace that is almost a mirror image does not replace what I want.
So this is my sample code
<%@ Page Title="Tour" Lang...
How can I get ahold of assembly.dll.config in the bin of an executing application in .net?
...
OK, so this is more of an answer than a question, but after asking this question, and pulling together the various bits from Dustin Campbell, Egor, and also one last tip from the 'IObservable/Rx/Reactive framework', I think I've worked out a workable solution for this particular problem. It may be completely superseded by IObservable/Rx/...
IS THERE IS ANY Solution for My Problem
Hi all,
I want to read a PDF file having lots of text, images, tables in it. I want to read the entire file content by content page by page, from top to bottom.
For example:
The top of the page contains the Heading
Then on left hand side the contents and on the right hand side images
So I fir...