|
ups... sorry aspdotnetdev! ok! my answer was:...............
Perhaps you can use Server.Transfer("url");[^] instead of Response.Redirect("url");.....
good luck
|
|
|
|
|
Hi.
I have an array of images like:
Image[] images = new Image[3];
After populating it with three images, i want to remove all of them and prepare it for the next set of three images by clearing the array. i have tried:
images.Clear();
as in an array but this does not work. How do i remove the images?
Thank you in advance.
Wamuti: Any man can be an island, but islands to need water around them!
Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.
|
|
|
|
|
Have you tried repeating step 1
images = new Image[3];
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Wamuti wrote: How do i remove the images?
What do you mean by "remove"? you can't remove anything from an array, each element will be there, all you can do is replace it, possibly by null.
If you want a variable number of elements, use a real collection such as a List<Image>
If you are worried about memory clean-up (and you should), then call Dispose() on each non-null element before replacing it by something else (unless the same image is still needed elsewhere).
|
|
|
|
|
If you want the elements to vary and you want to keep using an array and you don't want to reference a new array, you could always try:
Image[] images = new Image[3];
Array.Resize<Image>(ref images, 0);
Array.Resize<Image>(ref images, 4);
|
|
|
|
|
Two days in row, two different questions (yesterday's problem is solved by the way )
This is another one where I need some creative ideas...
I need to find all groups of items in an array. In this case same items in a different order means same group. The array/set/... is prepared by some methods that are executed earlier. This means I could start with 1 item, but with 250 items as well.
Let's suppose the generated array/set/... contains 5 items A, B, C, D and E. The groups I should get as result are the following:
A - B - C - D - E
AB - AC - AD - AE - BC - BD - BE - CD - CE - DE
ABC - ABD - ABE - ACD - ACE - ADE - BCD - BCE - BDE - CDE
ABCD - ABCE - ABDE - ACDE - BCDE
ABCDE
I don't need to reuse the combinations afterward. I just need the algorithm to perform a check routine on each group (and it occurs on only one place in my program). A little like "loop { check(group) }"
Thanks in advance for your ideas!
modified on Friday, April 30, 2010 4:21 AM
|
|
|
|
|
That looks like the power set minus the empty set
How about (in pseudocode - untested):
void TestAll(int i)
{
if (i == numberOfItems)
{
check(test-set)
return
}
TestAll(i + 1)
add input[i] to the test-set
TestAll(i + 1)
remove input[i] from the test-set
}
It includes the empty set but oh well..
Just an idea - I can't test it now though because I have to go, I'll be back in 8 hours or so
|
|
|
|
|
At first glance it looks good but I don't really understand what you mean. Could you (or somebody else) post a code snippet? Thanks in advance!
|
|
|
|
|
Here's another way of looking at it:
You have a binary number with as many bits as you have items. E.g. for ABCDE you'd have a 5-bit binary number. You then go through all the possible binary numbers of this length (i.e. the power set):
00001
00010
00011
00100 etc...
(In this case you'd ignore 00000 (no items)).
Where there's a 1 bit, you select the item. So the first four groups would be:
E (from 00001)
D (from 00010)
DE (from 00011)
C (from 00100)
This will go through every possible group of selections from the items, without regard to order.
|
|
|
|
|
With my Combinations extension method, I can do:
char[] b = new char[] { 'A' , 'B' , 'C' , 'D' , 'E' } ;
for ( int i = 1 ; i <= b.Length ; i++ )
{
foreach ( System.Collections.Generic.IList<char> a in b.Combinations ( i ) )
{
foreach ( char c in a )
{
System.Console.Write ( "{0} " , c ) ;
}
System.Console.WriteLine() ;
}
}
|
|
|
|
|
I've continued looking while I was waiting for answers and I found a quite simple way to do this. For my program, I had to build in a treshold calculation for performance purposes, but that's already done. Just the loops:
class ComboSearcher {
private string[] _arCombos;
private int[] _arIndeces;
private string[] _arSourceArray;
public ComboSearcher(string[] SourceArray) {
_arSourceArray = SourceArray
}
private void AddItemInt(ref int[] ArrayToUpdate, int ItemToAdd) {
int[] tmpArray;
tmpArray = new string[ArrayToUpdate.length];
for(int i=0; i<ArrayToUpdate.length; i++) {
tmpArray[i] = ArrayToUpdate[i];
}
ArrayTuUpdate = tmpArray;
}
private void CutArrayInt(ref int[] ArrayToCut, int NewLength) {
int[] tmpArray;
tmpArray = new int[NewLength];
for(int i=0; i<NewLengh; i++) {
tmpArray[i] = ArrayToCut[i];
}
ArrayToCut = tmpArray;
}
private void SubCheck(int IndexNumber) {
int i, j, minCount;
_arCombos = new string[0]
AddItemInt(_arIndeces, 0);
if(_arIndeces.lengh > 1) {
minCount = _arIndeces[_arIndeces.length - 2);
}
else {
minCount = 0;
}
for(i=minCount; i<_arSource.length; i++) {
_arIndeces[IndexNumber] = i;
for(j=0; j<=IndexNumber; j++) {
}
if(_arIndeces.length<_arSourceArray.length) {
CutArrayInt(_arIndeces, IndexNumber + 1);
}
}
}
public string[] Combinations() {
_arCombos = null;
SubCheck(0);
return _arCombos
}
}
Usage:
ComboSearcher cboSearch;
cboSearch=new ComboSearcher(source);
target=ComboSearcher.Combinations();
|
|
|
|
|
If you have 64 items or less (you better hope so, otherwise it will take forever) you could just use the bits in an ulong - that might complicate your check method a bit depending on your datastructures though
|
|
|
|
|
If you can find a copy, Volume 4 Fasicle 3 of Donald Knuth's The Art Of Computer Programming is pretty much the definitive work on combination generator algorithms.
Wikipedia's article[^] on the topic has a reference to Gosper's hack down at the bottom which may be of some use to you. It's a nifty hack to get the next highest number with the same number of 1 bits in the binary representation. Each bit of the output should correspond to an entry in your generated array. Run this for each bit count from 1 to the number of items in your array and you should have your combinations.
Of course, if you have more than a few items in your array, you should probably find some other way to check whatever it is you're checking. Generating combinations is order O(N choose t), so the running time is going to get big pretty quickly the more items you have in your array.
|
|
|
|
|
Hi everyone,
I'm writing a C# forms application to open an existing Excel workbook using the Excel Interop. Everything works fine. I can read and write fine. I do not save the workbook until the user close the C# application. The problem happens when my program is running and the user accidentally opens the same workbook with Excel. I get the error:
Exception from HRESULT: 0x800401A8
at this line
Range excelRange = worksheet.UsedRange;
Is there a way to lock the workbook and not allow the user to open it with Excel when my program is running?
Thanks
|
|
|
|
|
please any one can tell me when we need to generate event using delegates and please send me code of event handling using delegates.
thanks in advance
|
|
|
|
|
See here..., It may Help You..,
Delegates & Events [^]
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
|
A lots of resource on the internet. Why don't you try to search at google first.
Thanks
Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
i want to know site where i can download msdn for visual studio.
hi
My english is a little.
anyway, nice to meet you~~
and give me your advice anytime~
|
|
|
|
|
This was answered yesterday[^]
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
|
Hello Friends,
I want to search a folder which is shared to "EveryOne", with its FileSyatemRigths.
I have a code:
ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from win32_share");
foreach (ManagementObject share in searcher.Get())
{
string path = share["Path"].ToString();
DirectoryInfo di = new DirectoryInfo(path);
DirectorySecurity ds = di.GetAccessControl();
DirectorySecurity myDirectorySecurity = di.GetAccessControl();
AuthorizationRuleCollection arc = myDirectorySecurity.GetAccessRules(true,true,typeof(System.Security.Principal.NTAccount));
myDirectorySecurity.RemoveAccessRule(new FileSystemAccessRule("EveryOne", FileSystemRights.FullControl , AccessControlType.Allow));
}
It gives me the all shared folder and tried to remove Sharing permission.
But it fails
i)if Sharing is not given to EveryOne
ii) If sharing is given to EveryOne but other than full control.
"Please suggest a way to retrive sharing folder having access given to Every one and then how to remove that access irrespective of Access
Permisssion"
Thanks in advance
|
|
|
|
|
Try this link.[^]
I hope this might be helpful to you.
Thanks
Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
I've created a window service. In the OnStart() event a process is started to invoke a console application. Now in the OnStop() ctrl c need to be passed to the previously opened process (console app). Please let me know the way to do it.
"Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)
|
|
|
|
|