.net

Assigning a value (or any other parameter) to asp:checkbox

i'm pretty sure it's not possible, but i'll throw this out there anyways. I have about 10 asp:checkbox controls on the page, and I need to go and update the database every time any of them gets checked/unchecked. Right now i have all of them tied to one event handler that fires on CheckedChanged, then i cast the sender to Checkbox a...

Cloning List<T>

I thought that to clone a List you would just call: List<int> cloneList = new List<int>(originalList); But I tried that in my code and I seem to be getting effects that imply the above is simply doing: cloneList = originalList... because changes to cloneList seem to be affecting originalList. So what is the way to clone a List? E...

Parse String to Integer (come hell or high water)

I need to maintain a legacy VB.Net web application. Data typing is, I would say, inconsistent. Especially, there are data that is stored sometimes as integers and sometimes as strings and I have to parse strings to integers reliably. If parsing goes wrong it should always return 0. The problem is, I can't use any of the .NET/VB.Net pars...

LinkedList(T) add-method

The Add-method from the ICollection(T) interface has been explicitly implemented by the LinkedList(T)-class. This collection instead have AddFirst- and AddLast-methods (among others). The explicitly implemented method maps to the AddLast-method. This has some drawbacks and IMHO no benefit at all. The two major drawbacks are this: You c...

Existing sales/ordering engine that can be integrated to custom .NET app ?

Hi guys, There's this custom who wants software to generate quotes from a product catalog, print invoices, nothing too original here. But they also want a bunch of custom features and a custom presentation, so buy off-the-shelf won't do. Do you know any good product that we could integrate in the custom dev instead of reinventing the w...

Ensure uniform (ish) distribution with random number generation

I have a list of objects and I would like to access the objects in a random order continuously. I was wondering if there was a way of ensuring that the random value were not always similar. Example. My list is a list of Queues, and I am trying to interleave the values to produce a real-world scenario for testing. I don't particularly...

C# lambda - curry usecases

I read This article and i found it interesting. To sum it up for those who don't want to read the entire post. The author implements a higher order function named Curry like this (refactored by me without his internal class): public static Func<T1, Func<T2, TResult>> Curry<T1, T2, TResult>(this Func<T1, T2, TResult> fn) ...

Finding the hosting PropertyInfo from the MethodInfo of getter/setter

Hi, I do some type analysis in runtime using Reflection. If I have a MethodInfo instance, how can I figure out if this is a "real" method or is a getter/setter method of a property? And if it is a property, how can I find the its hosting PropertyInfo back? ...

Learning Days C#

How can i learn next wednesday, monday in a week? Forexample Today 06.02.2009 next Monday 09.02.2009 or wednesday 11.02.2009 there is any algorithm? i need : which day monday in comingweek? findDay("Monday") it must return 09.02.2009 ===================================================== findDay("Tuesday") it must return 10.02.200...

Accessing a .NET Assembly from classic ASP

I have been trying to access a .NET Assembly that I have created in classic ASP using dim foo set foo = Server.CreateObject("TestAssembly.MyClass") The problem is I'm getting an error: Server object error 'ASP 0177 : 800401f3' Server.CreateObject Failed /test.asp, line 4 Invalid class string I have registered the assembly (TestA...

.NET assemblies spanning multiple files and unit testing

Can anyone point me to some information on .NET assemblies spanning multiple files? I've found this remark on MSDN (here): Although it's technically possible to create assemblies that span multiple files, you're not likely to use this technology in most situations. I'm asking because I have the business logic and the unit test...

How can I determine property types using reflection?

How would I test a property of a type to see if it is a specified type? EDIT: My goal is to examine an assembly to see if any of the types in that assembly contain properties that are MyType (or inherited from MyType). Here is the track I've gone down... AssemblyName n = new AssemblyName(); n.CodeBase = "file://" + dllName; Assembly ...

Hook application with .NET to capture double click events

How can I hook an application so that I can find out when the mouse is double clicked within it? Can this be done in .NET? Are there anythings I should be careful about? (crashing the other application, for instance) ...

Can I modify/extend a production web service without affecting existing clients?

I am currently calling a web service that returns a service defined class which I am interpreting in my application. I'm considering asking the vendor of this web service to add a property to this class which will make my life as well as their other clients lives a lot easier. To be clear I'm not asking them to modify existing behaviou...

Will there ever be a solution for global events in .NET applications

In our program we use Microsoft's UserActivityHook.dll to determine when a user of our Windows Forms app has been idle for more than X seconds. This allows us to replicate an 'auto-away' behavior much like MSN/Live Messanger when there has been no keyboard or mouse events after a certain amount of time. Ive always wondered why .NET (to...

Checking if .NET is installed from the command line

Is there anything similar to the following in Windows that will let me know if .NET is installed from the command line? $ java -version $ ruby --version $ python --version ...

Does resizing jpeg images affect their compression?

Hello. I'm resizing jpegs by using the Graphics.DrawImage method (see code fragment below). Can anyone confirm that this will not affect the compression of the new image? I have seen this thread, but I am talking specifically about compression of jpegs. private byte[] getResizedImage(String url, int newWidth) { Bitmap bm...

What is the correct way to check if a path is an UNC path or a local path?

The easiest way to check if a path is an UNC path is of course to check if the first character in the full path is a letter or backslash. Is this a good solution or could there be problems with it? My specific problem is that I want to create an System.IO.DriveInfo-object if there is a drive letter in the path. ...

Identical Types In Separate Web Services

I have a similar problem as this question. I have multiple web services that I am consuming with WCF, which all share types. The services themselves are written in Java and I do not have access to them. The shared types have the same signatures, but svcutil.exe gives this error when running: Error: There was a validation error on a sche...

What's the use of System.String.Copy in .NET?

I'm afraid that this is a very silly question, but I must be missing something. Why might one want to use String.Copy(string)? The documentation says the method Creates a new instance of String with the same value as a specified String. Since strings are immutable in .NET, I'm not sure what's the benefit of using this method, a...