.net

Do we have sorting and searching function in .net

I was implementing linear search for search in a collection then i thought why not use binary search, for which i had to use sorting. Although I can implement them, but I would like to know where does they exists in .net itself. I hope it would be present in .Net. ...

SortedSet<T> and anonymous IComparer<T> in the constructor is not working

How come anonymous functions works as arguments on methods, but not in constructor arguments? If I create a List<string>, it has a Sort method with the following signature: public void Sort(IComparer<T> comparer) where the following works: List<string> list = new List<string>(); list.Sort( (a,b) => a.CompareTo(b) ); SortedSet ha...

What is this design pattern used in Enumerator.?

I've seen this pattern in Enumerator. It makes sure the collection haven't been altered while enumerating over the items. public class Versioned { internal int version = 0; public void ThisBreaksVersion() { version++; } } public class WorksOnVersioned { private readonly int version; private readonly Ver...

netstat command on a server (winform application)

Hello, I'm looking for how to recorgnize some server (windows in my case) network configuration (information we obtain using netstat dos command). I have the login and password of the target (server), and I developp with visual studio 2005 (c# or vB.NET doesn't matter). (Can I use WMI for that ???) Regards, ...

How to override GetHashCode() for value types in a good way?

Possible Duplicate: What is the best algorithm for an overridden System.Object.GetHashCode? As I understand it, there's a recommendation to override the base type GetHashCode() for my own value types. I have a hard time finding good resources on the actual how to implement a good hash code scheme for different kinds of value t...

Nothing equals String.Empty, null does not equal String.Empty, what am I missing here?

This must've have been asked before but I couldn't locate it. In a mixed code project (VB and C#) we were debugging some old Visual Basic code where a statement as follows could be found: If Request.Params("xxx") <> "" Then 'do something I considered this a bug as Request.Params could be null, in which case the statement would've b...

Why Tuple's items are ReadOnly?

I was thinking to use Tuple class to store 2 integer information (StartAddress, EndAddress) I need in my program. But I discover that Tuple items are ReadOnly, so if I need to set a value for an item, I need to re-instantiate a Tuple. What is the reason behind this design decision? ...

Why there is no IDateTimeProvider in .NET and DateTime has Now getter?

Currently I'm writing a unit test for a component that does datetime specific validation. I have created IDateTimeProvider interface, that serves as a DateTime.UtcNow wraper and business objects use interface rather than DateTime directly. It seems that DateTime is a bit overloaded and should be split into a value and a thing that gets t...

Convert ReadProcessMemory output to string

I am using ReadProcessMemory in C# output is bytes[]. I want to covert this to string. How to do that? My code is below.. !ReadProcessMemory(appProcess.Handle, mbi.BaseAddress, buffer, mbi.RegionSize, ref nRead)) { int lastError = Marshal.GetLastWin32Error(); if (lastError != 0) throw new ApplicationException(string.For...

How can I get the WorkflowInstanceId when implementing an ExternalDataExchange service?

I'm building an app to manage employees' holiday requests, with Windows Workflow Foundation handling the core logic. I want to develop a simple workflow that will be started when a request is created, and perform tasks based on whether the request is approved or rejected. Once the request is created, the workflow sends out notification ...

Region.IsVisible() not working as documented (?) [GDI+]

I see that Region.IsVisible(rectangle) is not working as I expect. So, is me who expect that should not, or is the method that is doing not that it should ??! I have the following situation: And the following code: private void Form1_Paint(object sender, PaintEventArgs e) { Point[] points1 = new Point[] { new Point(50, ...

WebRequest is getting generated from another IP instead my system IP?

Hi, I have the following code which bypass the proxy server for local machine and then send a WebRequest. System.Net.HttpWebRequest Request; System.Net.WebResponse Response; System.Net.CredentialCache MyCredentialCache; Edit 1 //System.Net.WebProxy proxyObject = new...

SharpDevelop equivalent of Visual Studio's "Break on exceptions"

In Visual Studio, there's a debugger setting labelled "Break on exceptions" or something like that. It drops into the debugger whenever an exception is raised (that is, on the first pass of the two pass exception mechanics), regardless of whether the exception will be handled or not. This is a very useful feature, and I try to keep it ...

How to add exe as reference in my web application

Hi all, I have created an exe with some methods in it (ref example exe below). using System; using System.Collections.Generic; using System.Text; namespace SampleRef { public class Program { static void Main(string[] args) { } } public class Sample { public Sample(int count) ...

Where did variable = null as "object destroying" come from?

Working on a number of legacy systems written in various versions of .NET, across many different companies, I keep finding examples of the following pattern: public void FooBar() { object foo = null; object bar = null; try { foo = new object(); bar = new object(); // Code which throws exception. ...

VB.NET and NUnit - TDD

Hi, I'm learning TDD with VB.NET and NUnit. I want to know what's the best thing to do: Use a lot of Assert methods inside of a test method or use a assert per method? This is my code. Thank you. Imports NUnit.Framework <TestFixture()> _ Public Class CalculatorTest <Test()> _ Public Sub TestAdd() Dim calculator As Calculator = New...

How do I use only one DataSet for the RDLC report designer as well as for the ReportViewer?

When designing an rdlc report using the VS 2010 report designer, report items such as charts demand a dataset. After designing the report, I add a ReportViewer to a webform, and it demands all of its own datasources. How do I hook up the DataSet I have coupled to the report without duplicating the DAL functionality in the viewer page? ...

What are recommended approaches for migrating from 2-tier NHibernate to 3-tier with SOA (Microsoft CRM)?

Given a (current) project that implements a 2-tier architecture with a well-separated on-tier business layer following the typical generic DAO architecture as pioneered by Bill McCafferty on CodeProject and explained briefly in chapter 10 of NHibernate in Action. This project must be moved to do CRUD operations and business logic throug...

oracle 9i: ora-12705 invalid or unknown nls parameter value specified

I have an Oracle 9i DB installed at remote IBM AIX server. I want to connect to it using C# app (.Net) Presently, I am able to connect to it using SQL Developer and SQLPlus from my machine. But when I try to connect from Visual Studio App, using System.Data.OracleClient. private static string GetConnectionString() { ret...

OracleClient, intermittent connection issue: app hangs on OracleConnection.Open(), no timeout, no exception thrown

Application works fine and connects every single time from any machine except the server, where it's supposed to be deployed :/ When run on the server it manages to connect once in like 20 or something attempts. Judging on the funky symptoms, I suspect it to be some kind of a network configuration related issue (as in some randomly lost ...