|
LOL, I just now saw that I mis-spelled 'No'
Christian Graus wrote:
Are you sure ?
No, I'm never sure of myself; to become sure makes me ignorant of other possibilities. I am confident in my answers though but I leave myself open to other solutions
Christian Graus wrote:
Actually, I think someone else fixed it for me...
Wonder who?
I think when we've got the screensaver pretty hammered out I'll write an article on using resources. Then I need to write part two to Nish's Registry article
James
Simplicity Rules!
|
|
|
|
|
James T. Johnson wrote:
I think when we've got the screensaver pretty hammered out I'll write an article on using resources. Then I need to write part two to Nish's Registry article
I'd considered trying to hammer out a decent registry class. I still have my bottleneck detector code waiting for an article, as well. I'd like to get a decent article up on the screensaver as well, sometime soonish.
I'd love to read an article on using resources, I couldn't get that thing you did to put them into a subfolder to work at *all*.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
James T. Johnson wrote:
Bitmap myJPG = new Bitmap(GetType(), "myPicture.jpg");
James, if I wanted to draw this image in a random location on the screen after I create my graphics object Graphics grfx; , what method do you suggest, there are 30 of them with just the .DrawImage() method(s).
Nick Parker
|
|
|
|
|
If you just want to Draw it without modifications, use DrawImageUnscaled; each of the other variations of DrawImage let you do slightly different things, about half of them doing the same but taking RectangleF/PointF instead of Rectangle/Point.
James
Simplicity Rules!
|
|
|
|
|
Or you can change the Bounds of the PictureBox... do you use a picture box!?
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
C++ allows to use default values for parameters e.g.
void MyFun(int nParam1, nDefault = 0);
Is it possible in C#? If yes, how to do it?
|
|
|
|
|
void MyFun(int nParam1)
{
MyFun(nParam1, 0);
}
void MyFun(int nParam1, int nDefault)
{
}
In other words, No...
|
|
|
|
|
Clever
|
|
|
|
|
Default parameters are not inherently supported in C#. You need to define an overloaded version of the method that doesn't require the parameter (that defaults it) and call the version that contains all the parameters. Before you say it, I agree that it sucks
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
How could they leave out something so trivial to impliment, and so useful ? Templates I can understand given that Microsoft are yet to release a worthwhile implimentation of templates on any platform, but this just blows.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
we've had many talks with Eric Gunnerson about this on the aspfriends.com email lists.
you may disagree with it...
but the reason they didn't implement it was because they favored ( by a small margin ) overall simplicity against More Features©
however, we have been fairly successfull at giving good arguments for it... and they are still considering it for v2.
|
|
|
|
|
lol, beat me to it
James
Simplicity Rules!
|
|
|
|
|
The more I use C#, the more it treats me like an idiot. It's clear to me they went for simplicity, for the benefit of people coming over from VB, I suspect.
Thanks for the insight.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
This is actually not the case. According to the C# Product Manager it had more to do with versioning than anything.
Cheers,
Tom Archer
Author, Inside C#
Author, Visual C++.NET Bible
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af
|
|
|
|
|
|
It's a percieved issue with distributed libraries ? Given that people are talking about doing the same thing via two functions, the hard coded values are still there, we're just finding ways around the limitation in C#.
But of course, I should be telling Joe this
Thanks for the info. BTW, Amazon shipping my copy of Inside C# on the weekend, so the delay was not that bad. Soon I will actually start learning me some C# instead of flailing around blindly. The Petzold book is helpful when I have a UI issue, but the other book I have, I have quickly outgrown.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Christian Graus wrote:
It's a percieved issue with distributed libraries ? Given that people are talking about doing the same thing via two functions, the hard coded values are still there, we're just finding ways around the limitation in C#.
Agreed. There were many situations where the reason for omitting something from C# that most C++ developers would consider important was due to versioning
Christian Graus wrote:
But of course, I should be telling Joe this
I'm sure he's heard it
Christian Graus wrote:
BTW, Amazon shipping my copy of Inside C# on the weekend, so the delay was not that bad
Very cool! I'll be here for any questions.
Cheers,
Tom Archer
Author, Inside C#
Author, Visual C++.NET Bible
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af
|
|
|
|
|
|
Here is what Eric Gunnerson had to say about the subject on the aspngcs list.
[The discussion was regarding optional parameters in VB, but they are essentially the same thing]
I'd like to try to share a bit of the language designer perspective to this.
When we look at features, the question that we try to answer is:
Is the utility that this feature adds worth the additional complexity in the language?
When we did this for C#, there were a number of cases where the tradeoff isn't clear-cut. Our default decision is not to add a feature, because simplicity is also a feature. To put this another way, C# is already more complex than we'd like it to be, so additional features have to be really useful to meet the cut.
Then later,
I appreciate the feedback. I'm not sure you have to persuade me - I'm pretty much on the fence on this one. You'd really have to persuade Anders...
I can give you a bit more perspective on this issue.
In C++, default parameters don't version well, because the default value ends up in the client code rather than your library. I think that's a pretty serious drawback, and I don't think it's the right approach for C#.
One other thing we've considered doing was having the compiler take a definition like:
public void (string s1, string s2 = null, string s3 = null)
{
}
and generate the other two overloads.
IIRC, we're planning on discussing this so more, but I don't know what the outcome will be.
If anyone wants I can e-mail them the thread (titled "Optional Parameters in C#" for those on the list).
James
Simplicity Rules!
|
|
|
|
|
James T. Johnson wrote:
To put this another way, C# is already more complex than we'd like it to be,
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
|
I just spoke with Joe Nalewabau (Product Manager for C#) and asked him why default params were not included in the language. I figured you might want to hear the "inside story":
[Joe Nalewabau] - Default parameters were not added due to the versioning issues associated with them. Essentially when you add default parameters the compiler essentially burns the default value in to the callers code when the code is compiled. This means that if you change the default values all clients must be recompiled to take advantage of the new value -
rather than have the class library itself decide what the default values should be.
Hope this helps.
Cheers,
Tom Archer
Author, Inside C#
Author, Visual C++.NET Bible
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af
|
|
|
|
|
Thank you for information. This is quite reasonable (but sometimes default parameters are very usefull
Tomiga
|
|
|
|
|
I'm with you. I'd rather have the default params. As Christian stated, people are just going to inject work-arounds to the lack of support for default params that are cause the same problems that resulted in their omission to begin with
Cheers,
Tom Archer
Author - Inside C#, Visual C++.NET Bible
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af
|
|
|
|
|
Hello All,
I'm having some problems reading values off a remote machine's registy. When I run the following code I get a System.NullReferenceException all the time. Any Ideas why ? Thanks in advance...
-Koby
using System;
using Microsoft.Win32;
namespace RegExlorer
{
class RegExplorer
{
public static void Main()
{
RegistryKey remoteKey;
object myObj;
// try to open HKEY_CURRENT_USER hive on remote machine
remoteKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.CurrentUser, "beast4-009");
// try to open (HKEY_CURRENT_USER\)Volatile Enviornment" hive on remote machine
remoteKey.OpenSubKey("Volatile Environment");
// get value
myObj = remoteKey.GetValue("USERDNSDOMAIN");
// print the result out to the screen
Console.WriteLine(myObj.ToString());
// wait for a key stroke
Console.ReadLine();
}
}
}
|
|
|
|
|