|
Yes, I think that does look better, and read better. I remember (dimly) once using a 'const named 'DigitBase for this.
But, if I were doing code requiring decomposing ints to lists of digits, I'd be using something like this ... from code written several years ago:
public const long TenBase = 10L;
public IEnumerable<long> IntToDigitList(long longint)
{
while (longint > 0)
{
yield return (longint % TenBase);
longint /= TenBase;
}
} To avoid mucking about with strings/chars. Code I probably got the idea from, if not the basis for this code, from StackOverFlow
«The truth is a snare: you cannot have it, without being caught. You cannot have the truth in such a way that you catch it, but only in such a way that it catches you.» Soren Kierkegaard
|
|
|
|
|
Tonight I banged my head against the wall while sleeping and I'm not feeling like reading a lot today but it looks like another excellent example of guiding rather than spoon feeding, so you get my upvote, Bill!
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Sascha Lefèvre wrote: Tonight I banged my head against the wall while sleeping Hi Sascha,
Ouch. Usually it is the walls who bang themselves against my head while I am trying to sleep; I am never sure if it is personal. Banging back at them is an idea I hadn't thought of.
I'd accept an up-vote from you, even if you were comatose.
cheers, Bill
«The truth is a snare: you cannot have it, without being caught. You cannot have the truth in such a way that you catch it, but only in such a way that it catches you.» Soren Kierkegaard
|
|
|
|
|
Looks pretty trivial.
What is your problem with this ?
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
Hi,
I was given following question as an assessment but unfortunately I was unable to answer. Can someone help ?
The question is ;
The function given below is supposed to retrieve the substring between and including the ith and jth characters of the input string s. When i and j are out of range, ie. i,j< 0 ori,j >= s.length(), the function returns the string "<error>". The following table shows the expected and actual return values of the function for various inputs.
Test case s i j Expected return value Actual return value
1 "quick" 0 2 "qui" "qui"
2 "brown" 2 1 "ro" ""
3 "fox" 1 9 "<error>" "<error>"
4 "jumped" -1 4 "<error>" "<error>"
5 "lazy" 3 0 "lazy" "<error>"
6 "dog" 1 1 "o" "o"
Unfortunately, the function returns the wrong value for the 2nd and 5th test cases.
C# Version:
string SubString(string s, int i, int j)
{
int k;
string result;
try
{
k = s.Length;
if (i < 0 || j < 0 || i >= k || j >= k)
throw new Exception();
result = s.Substring(i, j + 1 - i);
}
catch (Exception e)
{
return "<error>";
}
return result;
}
a) Under what general conditions does the function return the wrong value?
b) Add some code to fix the function. Can you improve it? If so explain why your version is better.
|
|
|
|
|
A glance at those cases shows that when j is less than i it still sends a valid substring. This is not correct, the code should test for such a condition. Now it's up to you to fix the code.
|
|
|
|
|
Hello,
I have an application, Main, that is big enough to make debugging new components tedious. I developed another module(Sub) separately which I intended to pull into the Main when it was up and running. It has its own namespace but uses a lot of things from Main by way of linked files. When things were working I brought it into Main by adding an existing project. That all works fine inside the IDE.
I can compile and run Main.exe as a Release. It runs in the Bin\Release folder, which means, when I click the menu item the window for Sub opens as planned.
However when I move Main to Desktop or another folder and try to run it I get:
"System.IO.FileNotFoundException occurred in PresentationCore.dll"
Could not load file or assembly (Sub)'Treat04', Version =1.0.0.0, The system cannot find the file specified.
It looks like it is compiling two separate jobs. I want it all wrapped up as a single Release application.
Thanks for any suggestions,
Russ Fisher
|
|
|
|
|
You need to move Sub also. The system has a default list of directories to search and your project directory is not in the list, except when you run the application from within that directory.
|
|
|
|
|
Hello,
I have developed an application which has all the filter options of windows search in a single window. I want to add this application to Windows Explorer's menu.
How can I achieve this ?
Please help.
|
|
|
|
|
You are going to have to write a Browser Helper Object (BHO) that interacts with Explorer. Bear in mind that BHOs were originally introduced to extend IE but were extended to work with Explorer, so you are going to have to do a bit of work to make it work only in Explorer. Then you're going to have to do some pure COM interop work I'm afraid. You should get some idea on what you need to do here[^].
This space for rent
|
|
|
|
|
|
Why is it not working for you?
|
|
|
|
|
If you wanted help with a specific task, then it would make sense to state that in the original question. You might also want to explain "how" it is not working for you, otherwise you'll simply get alternative options. Did it compile? Did it throw an exception? If yes, what did the exception say? Did you follow the instructions on the page you linked? Up to where does it work?
AFAIK, adding a button would require a Shell Band Object[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Why I don't know. Since it deals with only registry It is not possible to trace the error. Also very less references are available for this work.
|
|
|
|
|
srikrishnathanthri wrote: Since it deals with only registry It is not possible to trace the error Did you change the permissions for the registry keys as suggested in the article? Sounds like that is the part most likely to go wrong. You might also want to try to contact the author by adding a comment there.
I cannot see whether this works on any other platform than Windows 7.
The deskband-solution would be my first choice, and MSDN[^] the starting point.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I have changed the permissions. Without giving permission it is not possible to add the keys to that hives. Yes, It is working in only Windows 7.
|
|
|
|
|
Hi everyone i want to read rar file name and folder in this rar file but i dont know how i can do it
|
|
|
|
|
I would suggest a Google search for "how to read rar file" or similar.
|
|
|
|
|
|
There are many Unzip API available, that you can use to unzip your RAR file.
IonicZip.dll is one of the most used zip/unzip library you can use. Here is code snippet
ZipFile zipFile = new ZipFile("Path TO Your ZIP File");
zipFile.ExtractAll(Application.StartupPath);
see below link to download API
DotNetZip Library - Home[^]
SevenZipSharp - Home[^]
Find More .Net development tips at : .NET Tips
The only reason people get lost in thought is because it's unfamiliar territory.
|
|
|
|
|
Hi,
1. I am developing an application in C# in which I want to disable all the mass storage USB devices except a few USB based hard disk (as white list hard disk).
2. Am trying to make logic in which I would like to make my my white-list based on internal serial number of hard disks (USB based ). This white-list I will try to populate and try to read as configuration file for my utility.
3. Thereafter, I will try like to compare all the incoming USB mass storage devices internal serial number with my white list serial numbers to filter them and extend the access permission based on positive matching else disable them if not matching with my white-list serial number of hard disk.
4. Now I know how to disable the USB Mass storage but am not able to get the USB mass storage serial number of all incoming USB devices in real time and also how to supply my white-list of UBS mass storage hard disk serial number during the run-time of my application.
Thanking you all in advance for your kind reply.
regards
Deepeshonly
|
|
|
|
|
So what is your actual question?
|
|
|
|
|
how I can disable all the USB mass storage devices except a few based on internal serial number of USB hard disk (as per my white list) in the C# program.That is when ever some connecting any USB devices then PC should able to block it if it is not matching with my white list of hard disk serial numbers.Whit list hard disk serial number I would like to read as configuration file.
|
|
|
|
|
how I can disable all the USB mass storage devices except a few based on internal serial number of USB hard disk (as per my white list) in the C# program.That is when ever some connecting any USB devices then PC should able to block it if it is not matching with my white list of hard disk serial numbers.Whit list hard disk serial number I would like to read as configuration file.
thanks n regards
|
|
|
|
|