|
That's an int. An int has no format at all, decimal is just assumed. Use the overloaded ToString method to specify a hex format, or whatever else you like
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I don't want to save the address to XML via C#, I want to read the address from the XML. Sorry I wasn't specific enough.
|
|
|
|
|
|
riving license (class)
+number: string (constructor)
+renewelperiod: int (constructor)
+ GetLicenseInfo():void (mrthod)
+ CalculateLicensePrice(): double (method)
+ DisplayLicenseInfo() : void (method)
Based on the above, create a program with the following requirement
• GetLicenseInfo() method that input license number and renewal period from user. Display an information to the user either to renew the license for 1,2,3 or 5 years.
• CalculateLicensePrice() method that will calculate price for driving license depends on the renewal period of 1,2,3 or 5 years. The renewal fee is RM30 per year
• A method DisplayLicenseInfo() that will display each details including license number,renewal period and license price.
Create an object and invoke necessary method
|
|
|
|
|
what are you doing man?
|
|
|
|
|
Just because someone helped a person who asked a specific question, doesn't mean he'll do your homework. Imagine what this forum would look like if every person with a question started to hijack threads ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I am afraid that you have misunderstood Christian's suggestion in your previous post. You are supposed to ask a specific question, not somebody else...
Greetings - Jacek
|
|
|
|
|
Ignore the others - I'll help you. Of course, you'll have to pay the daily rates my company charges, but what the hell - we'll throw in a years support contract for a very reasonable fee. We will expect an initial payment before work commences, but once we have the contract in place, we'll be good to go.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi
In my application, I need capture when a user presses the key combination "alt-space". Can someone show me how to do this, please?
|
|
|
|
|
Try here[^]
or, if that isn;t enough, here[^]
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
OriginalGriff wrote: or, if that isn;t enough, here[^]
Are you a cool kid who wants to impress your friends and family with your mad skillz?
The second link made me laugh (like this: ). Cheers!
Greetings - Jacek
|
|
|
|
|
Yep, I was rather amused!!
|
|
|
|
|
Jacek Gajek wrote: Are you a cool kid who wants to impress your friends and family with your mad skillz?
If you think you're a "cool" kid who can impress people with 1337 programming skillz0r then you really need to go outside. I knew from the beginning that programming wasn't going to make me the life of a party, it's not right for Microsoft to lie to kids this way.
My current favourite word is: Sammidge!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Errr.
You are aware that Alt-Space is a standard Windows key combination, aren't you?
It opens the Control Menu for the active window, by default.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Henry Minute wrote: You are aware that Alt-Space is a standard Windows key combination, aren't you?
Yes, but that isn't SAS sequence and you can still capture it if you install a keyboard hook.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Rajesh R Subramanian wrote: and you can still capture it if you install a keyboard hook.
Hi Rajesh,
This is a bit late, I know, but I am having terrible problems with my ISP at the moment (I'm stuck on 53.6 kbps at the moment, when I can get a connection that is ).
My point was that Alt-Space is one of the less well known keyboard shortcuts but nonetheless some people do use it (me for instance) and because of that it might be worth the OP considering an alternative. There is little that is worse than using a 'standard' shortcut only to find that the app you are using has decided to use it for formatting the C: drive.
As far as I am aware you can capture any key combo with a global hook but whether you should is another thing.
Cheers!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I'm sorry about your connection speed but I had a laugh.
Henry Minute wrote: My point was that Alt-Space is one of the less well known keyboard shortcuts but nonetheless some people do use it (me for instance) and because of that it might be worth the OP considering an alternative.
There are many valid reasons to execute code when the user is pressing this key combo (amongst many other combos). For instance, if your application does not have a system menu, and you want to emulate it yourself. Or your application is largely ownerdrawn (we have an app where there's just one window and everything else is drawn as bitmaps in runtime) and it emulates a lot of stuff (context menu drawing, system menu drawing, cursor, etc.,) based on keyboard and mouse inputs. This can be done only with the help of a hook. And this is not going to affect the way other applications work (you execute your code, only if your window is active).
Henry Minute wrote: As far as I am aware you can capture any key combo with a global hook
Not any key combo. The SAS (Ctrl+Alt+Del) key combo is not something that can be trapped because it triggers a hardware interrupt that isn't notified of outside the ring0 level. (OK, may be that can as well be trapped, but that will require ninja windows programming skills). Even with ninja skills, it is almost impossible to trap it on x64 versions of Windows, because of Kernel Patch Protection.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Rajesh R Subramanian wrote: I'm sorry about your connection speed but I had a laugh
You are just evil.
Rajesh R Subramanian wrote: For instance, if your application does not have a system menu, and you want to emulate it yourself.
True, I hadn't considered that case. Nonetheless the OP should be made aware, if he wasn't already, of the existing use.
Rajesh R Subramanian wrote: (OK, may be that can as well be trapped, but that will require ninja windows programming skills)
As a coder currently at the Noneja level I'll leave that stuff to you guys.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
AndyASPVB wrote: In my application, I need capture when a user presses the key combination "alt-space". Can someone show me how to do this, please?
Hi,
You will need to write a keyboard hook for this purpose. Refer to the following article:
Processing Global Mouse and Keyboard Hooks in C#[^]
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Hi!
I am not sure how to express what I need. However...
I've got a code which generates all permutations of an array of numbers 0 to n-1, which can be used to generate permutations of any array, since every element can be mapped to it's index and vice versa.
Here it is:
public IEnumerable<int[]> GetPermutations()
{
if (n == 1)
{
yield return indexes;
yield break;
}
var generator = new PermutationGenerator(n - 1);
bool even = false;
foreach (int[] permutation in generator.GetPermutations())
{
if (even)
for (int i = 0; i < n; i++)
yield return InsertN(permutation, i);
else
for (int i = n - 1; i >= 0; i--)
yield return InsertN(permutation, i);
even = !even;
}
} In an algorithm I am currently writing, sometimes it is good to skip some permutations. E.g. I have reached [12345678], and realize that I don't need any perm. which starts with [123.....], so I would like to skip 5! permutations and go in one step to [124.....]. It basically means that I would like to put a "return " in a given level of recursion. The code would look like this I suppose:
foreach (int[] permutation in GetPermutations())
{
SkipPermutations(4);
} Of course I will not be satisfied with a solution like running empty for loop to skip a number of permutations.
The problem here is recursion. I have inspected an Enumerator class generated by a compiler using Reflector and it was very complicated. Any Ideas how to achieve it a simple and elegant way?
Thanks in advance --
Greetings - Jacek
|
|
|
|
|
Ok, my brain is kind of winding down, it being Friday and all, so I can't quite wrap it around your algorithm right now... But for skipping entries in the enumeration itself...
Basically, foreach is a shortcut for a more wordy but not very complicated code block:
IEnumerator<int[]> en = GetPermutations().GetEnumerator()
while (en.MoveNext())
{
int[] permutation = en.Current;
}
If you write this out yourself, you have a reference to the enumerator, so you can do this:
public bool SkipPermutations(IEnumerator en, int count)
{
for(;count > 0; count--)
if (!en.MoveNext()) return false;
return true;
}
Then you can just put this in the middle of your foreach:
if (!SkipPermutations(en, 4)) break;
The trick, of course, is that if you skip past the end of the enumeration, you'll get an exception... So you have to keep checking to see if you're at the end.
|
|
|
|
|
Thanks for answer, but...
I wrote: Of course I will not be satisfied with a solution like running empty for loop to skip a number of permutations.
Sorry, but I need to reduce time complexity by skipping permutations. That solution is pointless since it does these iterations anyway.
Greetings - Jacek
|
|
|
|
|
I was thinking of that, but like I said, hard to wrap my brain around your algorithm right about now...
What you could do is set a boolean flag on your generator class in the SkipPermutations function... And in GetPermutations(), you can "yield return 0" instead of running a block of code whenever you want to skip an entry. I'm not sure where exactly to put it though.
Basically MoveNext() will continue GetPermutations() until it hits the next "yield" statement. If it's a "yield return", it'll set the Current property to the result and return true... If it's a "yield break", it'll return false. So you just need GetPermutations() to "yield return 0" until the skip flag is turned off.
|
|
|
|
|
Ian Shlasko wrote: a boolean fla
Yeach I though about it before, but I have encountered implementation difficulties. Fortunately, harold posted an almost read-to-use out-of-the-box nice-and-elegent solution.
Greetings - Jacek
|
|
|
|
|
I know it doesn't answer the question, but may I suggest factoradic numbers[^]?
edit: then you could skip x iterations by just adding x to the "permutation number" Last modified: 24mins after originally posted --
|
|
|
|