Algorithm for & ldquo; consolidation & rdquo; N elements in K

I was wondering whether there's a known algorithm for doing the following, and also wondering how it would be implemented in C#. Maybe this is a known type of problem. Example: Suppose I have a class class GoldMine { public int TonsOfGold { get; set;

Save the path to the entire image

This question already has an answer here: Storing Images in DB - Yea or Nay? 56 answers I want to save the profile picture, and I want to know what is the best option. -Saving the path in the DB and load the image according to his location. -Save the

The event will not work with user control

I have a problem that I can't resolve on the server side of my project. I'll explain: I have a page named Global,this is ASP.NET page. This page uses a UserControl named CateGories. Now I have a button on this UC page,that when I press I want to invo

AES Decryption Exception modification

I have an AES Cryptography wrapper and unit tests that has been working for over a year. Now after installing VS 2012 (or maybe an update to .net Framework 4) the unit tests do not pass. The streamreader block was throwing a CryptographicException wh

Game Development - Avoiding Flicker

I am developing a tetris like game in winforms(C# and .netframework 2.0). The winform has an background image and a picture-box which move down(new Location is assigned) at an interval of 500ms. The problem is when picture-box moves down the backgrou

How to add a similar element of a structure array in vb.net?

I have an array of structures: Public Structure emp Public empName As String Public empAge As Int32 Public empsal As Int32 ' salary End Structure An array of the above structure with 30 element. I want to sum the empsal of those emp elements whose em

Code link height behind

I have a custom GridView like control made of a Grid panel with several controls in each row (All of them from System.Windows.Controls). The user requested that the row Height will grow unrestricted with the control's content. I'm having a problem to

Highlight the chain decimal value with the leading spaces

How do I format a decimal value to a string with a single digit after the comma/dot and leading spaces for values less than 100? For example, a decimal value of 12.3456 should be output as " 12.3" with single leading space. 10.011 would be "

C ++ port to C # - templates

I'm porting a C++ application to C#, and have run across templates. I've read up a little on these, and I understand that some templates are akin to .Net generics. I read the SO answer to this case which nicely summed it up. However, some uses of c++

Sending SMS text with line break / new line

I am developing SMS portal in asp.net c# where people register & send sms. I M Using multiline asp:textbox for input message. i want to break line where user hit enter/new line in textbox. help me if there any textboxeditor which support only <br/&

Performance of immutable data structures

I don't get how can something as a Set be immutable and still have an acceptable performance. From what I've read in F# Sets internally use Red Black Trees as their implementation. If each time we want to add something new to a Red Black Tree we have

In LINQPad can you access SYSOBJECTS using LINQ?

In LINQPad is there any way to access either the SYSOBJECTS table or the various INFORMATION_SCHEMA.xxx views using LINQ? I spend a lot of time searching through our huge company database for partial names as there are too many tables and Stored Proc

What is the benefit of WSDualHttpBinding in WCF?

So far, no one can really offer any benefit of using dual channel over a client polling system except for the immediate notification you can get from the dual channel. Every other point says if you dont need immediate notice the dual binding provides

WCF Service Call Wrapper

What is best practice for creating wrapper for WCF service call? I think it is necessary to monitor all calls in the same place, I am thinking to use this kind of code, is this right idea? RetType t = ServiceExecutionContext<IServiceChanel>.Execute(

How to diagnose ArgumentOutOfRangeException on SqlDbType?

We have some customers using our .NET 2.0 thick-client app that experience strange, intermittent errors reading data from a SQL 2000 SP4 Server, where the actions succeeded just moments earlier. We have some customers using SQL 2000 (and many using 2

Make a Windows .NET application appear on a keystroke

My application resides mostly on the system tray on minimize. I'd like the user to be able to hit a keystroke (like ALT+SHIFT etc.) and it shows up on the screen (sort of like Launchy, if you've used it; or the Google search bar). Anyone knows how to

Get the primary key of a new entry

I have a number of child tables that have a foreign key to a parent table. How do I add an entry in the parent table and get the primary key of that entry, so that I can then enter rows in the child tables that point to the entry in the parent table?