473,800 Members | 2,586 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using OUT in a method

hello everybody !
I get this error 3 times : "The output parameter must be assigned before
the control leaves the current method" (dor dMin and dMax)
this one 1 time : Use of the parameter 'out' is not assigned 'dMax'

This is my first steps in C#: i can't manage(understa nd) this error.

I would like to test to variables which can be change on form1 by 2 numeric
updown controls before sending them to a UserControl which make some
calculation with these 2 numbers like this :

if (_genData.Numbe rMin < _genData.Number Max)
{

S = (int)(_rand.Nex t((int)_genData .NumberMin,
(int)_genData.N umberMax + 1) / 3) * 3;
}

else
{
//Choisir le nombre cible (_iS) compris dans la fourchette
et le rendre multiple de trois.
// Set the target number (_iS) in the range and make
multiple of three.
So if user modify the value and nudNumMin .Value becomes nudNumMax
..Value the calculation could send an error in calculating the value S.
That's why i have to test and correct the values before sending them to the
UserControl.

the code in form1 is :
#region min max check
string message = "Attention ! Le nombre maximal doit être au
nombre minimal. L'erreur sera corrigée";
string caption = "Erreur dans le choix de la taille des nombres.";
MessageBoxButto ns buttons = MessageBoxButto ns.OK;
DialogResult result;

// this method checks the values and shows an error message if
// they are not as expected and corrects them to a valid state

public bool CheckMinMaxValu es(out int dMin, out int dMax)
{

if ( nudNumMin .Value nudNumMax .Value )
{
result = MessageBox.Show (message, caption, buttons);
dMin = dMax - 1;
return false;
}
return true;
}
#endregion //min max check

and then :

private void nudNumMax_Value Changed( object sender, EventArgs e )
{
int dMin = (int)nudNumMin. Value;
int dMax = (int)nudNumMax. Value;
if (!CheckMinMaxVa lues(out dMin, out dMax))
{
//... do what ever is needed when the check fails
nudNumMin.Value = dMin;
nudNumMax.Value = dMax;
nudNumMax.Value = nudNumMin.Value + 1;
_currParam.Gene rationData.Numb erMax = (int) nudNumMin.Value
+ 1; // for example

}
_currParam.Gene rationData.Numb erMax = (int)nudNumMax. Value;
ValueChanged( true );
}

I hope you understand me....
and can help me !
pascal
--
http://www.scalpa.info

Jun 27 '08
17 2238
Hi Jon,

you may be right. There are always two approaches to a problem. As I said
to Alun, I am making some minor changes. I am on the side of the fence that
believes that overall concepts are more appropriate for beginners than
finite details. I can understand that some people disagree with this
approach while some support it.

I have seen plenty of people learn quickly whilst looking at the fine
detail. I have seen equal numbers get bogged down in the detail and lose
interest. As I say, swings and roundabouts but always happy to take
constructive criticism.

--

BlackWasp
www.blackwasp.co.uk
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:84******** *************** ***********@p25 g2000pri.google groups.com...
On Apr 18, 10:11 am, "BlackWasp" <nospam@pleasew rote:
>I hear what you are saying but remember that this is a _fundamentals_
tutorial for beginners.

I would say that correctly differentiating between passing a reference
by value and passing a parameter by reference is quite fundamental. It
affects the whole mental model of how objects are stored.
>Some would say that the semantics are very
important. In my experience they may be but beginners can get too
wrapped
up in them and end up confused rather than developing.

I would personally rather beginners took a little bit longer to learn
the fundamentals, than came away with a broken mental model which is
much harder to undo later on.

Jon
Jun 27 '08 #11
On Fri, 18 Apr 2008 14:28:39 -0700, Jon Skeet [C# MVP] <sk***@pobox.co m>
wrote:
There's a difference between omitting fine details and stating
outright falsehoods, however. I'm fine with the idea of leaving a sign
saying "here be dragons" around particularly difficult bits, and
perhaps coming back to them later - but anything which encourages a
beginner to believe something which is actually untrue is a bad thing,
IMO - simply because "unlearning " is difficult.
This is such an important principle, it has a name: the "law of primacy"..
A Google search turns up surprisingly few hits, given its importance, but
what hits are there do a good job of explaining its importance.
http://www.google.com/search?q=%22law+of+primacy%22
I'm actually of the belief that the truth about the nature of
references and objects is easier to grasp than we think - it's just
*very* hard to write about clearly. The concept itself isn't that
hard, but explaining it is difficult. Personally I like the analogy of
a piece of paper for value types (to create a copy, you photocopy the
piece of paper) vs a web page for reference types (to tell a friend
about the page, you just give him a copy of the URL, rather than the
page itself).
Hmmm...one thing I think can be improved upon in that analogy is that the
piece of paper and the web page aren't really similar. It'd be a better
analogy if the thing representing a value type could be referred to by a
reference type.

Consider, perhaps, instead a library. Books are value types. The card
catalog entries are reference types. You can make copies of the card
catalog easily, and the cards always refer to the same book. But if you
copy a book, you've made a whole new book.

This is inaccurate too, since in reality a single reference doesn't refer
to a value directly, but something that contains a value (either a boxed
value, or a class containing values). But I think it's closer to what's
going on. :)
The bonus of this is that once this fundamental concept has been
grasped, all kinds of things become *much* easier to explain -
assignment, parameter passing, garbage collection, memory allocation
etc.
I very much agree with that. One way or the other, it's important to
teach the fundamentals correctly the first time. Using wrong descriptions
of what's going on can never help with simpler implementations , and it
always leads to incorrect implementations in more complicated scenarios
(how many times have we seen someone passing a class reference by
reference, because they thought that was more efficient than passing the
reference by value?)

Pete
Jun 27 '08 #12
Yup, still can't disagree with you. That's why I made some changes.

Take a look and drop me an email if you like. Won't post the address here
for obvious spammy reasons but drop me a line on the contact form by all
means.

--

BlackWasp
www.blackwasp.co.uk
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:8d******** *************** ***********@z24 g2000prf.google groups.com...
On Apr 18, 1:41 pm, "BlackWasp" <nospam@pleasew rote:
>you may be right. There are always two approaches to a problem. As I
said
to Alun, I am making some minor changes. I am on the side of the fence
that
believes that overall concepts are more appropriate for beginners than
finite details. I can understand that some people disagree with this
approach while some support it.

There's a difference between omitting fine details and stating
outright falsehoods, however. I'm fine with the idea of leaving a sign
saying "here be dragons" around particularly difficult bits, and
perhaps coming back to them later - but anything which encourages a
beginner to believe something which is actually untrue is a bad thing,
IMO - simply because "unlearning " is difficult.

I'm actually of the belief that the truth about the nature of
references and objects is easier to grasp than we think - it's just
*very* hard to write about clearly. The concept itself isn't that
hard, but explaining it is difficult. Personally I like the analogy of
a piece of paper for value types (to create a copy, you photocopy the
piece of paper) vs a web page for reference types (to tell a friend
about the page, you just give him a copy of the URL, rather than the
page itself).

The bonus of this is that once this fundamental concept has been
grasped, all kinds of things become *much* easier to explain -
assignment, parameter passing, garbage collection, memory allocation
etc.

Jon
Jun 27 '08 #13
The Law of Primacy is very important indeed! I certainly would agree that
stating outright falsehoods is a bad thing.

--

BlackWasp
www.blackwasp.co.uk
"Peter Duniho" <Np*********@nn owslpianmk.comw rote in message
news:op******** *******@petes-computer.local. ..
On Fri, 18 Apr 2008 14:28:39 -0700, Jon Skeet [C# MVP] <sk***@pobox.co m>
wrote:
There's a difference between omitting fine details and stating
outright falsehoods, however. I'm fine with the idea of leaving a sign
saying "here be dragons" around particularly difficult bits, and
perhaps coming back to them later - but anything which encourages a
beginner to believe something which is actually untrue is a bad thing,
IMO - simply because "unlearning " is difficult.
This is such an important principle, it has a name: the "law of primacy".
A Google search turns up surprisingly few hits, given its importance, but
what hits are there do a good job of explaining its importance.
http://www.google.com/search?q=%22law+of+primacy%22
I'm actually of the belief that the truth about the nature of
references and objects is easier to grasp than we think - it's just
*very* hard to write about clearly. The concept itself isn't that
hard, but explaining it is difficult. Personally I like the analogy of
a piece of paper for value types (to create a copy, you photocopy the
piece of paper) vs a web page for reference types (to tell a friend
about the page, you just give him a copy of the URL, rather than the
page itself).
Hmmm...one thing I think can be improved upon in that analogy is that the
piece of paper and the web page aren't really similar. It'd be a better
analogy if the thing representing a value type could be referred to by a
reference type.

Consider, perhaps, instead a library. Books are value types. The card
catalog entries are reference types. You can make copies of the card
catalog easily, and the cards always refer to the same book. But if you
copy a book, you've made a whole new book.

This is inaccurate too, since in reality a single reference doesn't refer
to a value directly, but something that contains a value (either a boxed
value, or a class containing values). But I think it's closer to what's
going on. :)
The bonus of this is that once this fundamental concept has been
grasped, all kinds of things become *much* easier to explain -
assignment, parameter passing, garbage collection, memory allocation
etc.
I very much agree with that. One way or the other, it's important to
teach the fundamentals correctly the first time. Using wrong descriptions
of what's going on can never help with simpler implementations , and it
always leads to incorrect implementations in more complicated scenarios
(how many times have we seen someone passing a class reference by
reference, because they thought that was more efficient than passing the
reference by value?)

Pete

Jun 27 '08 #14
On Apr 18, 2:51 pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:
There's a difference between omitting fine details and stating
outright falsehoods, however. I'm fine with the idea of leaving a sign
saying "here be dragons" around particularly difficult bits, and
perhaps coming back to them later - but anything which encourages a
beginner to believe something which is actually untrue is a bad thing,
IMO - simply because "unlearning " is difficult.

This is such an important principle, it has a name: the "law of primacy".
A Google search turns up surprisingly few hits, given its importance, but
what hits are there do a good job of explaining its importance.http://www.google.com/search?q=%22law+of+primacy%22
I'm glad it's a properly documented phenomenon rather than just my
intuition (and observations on newsgroups).
I'm actually of the belief that the truth about the nature of
references and objects is easier to grasp than we think - it's just
*very* hard to write about clearly. The concept itself isn't that
hard, but explaining it is difficult. Personally I like the analogy of
a piece of paper for value types (to create a copy, you photocopy the
piece of paper) vs a web page for reference types (to tell a friend
about the page, you just give him a copy of the URL, rather than the
page itself).

Hmmm...one thing I think can be improved upon in that analogy is that the
piece of paper and the web page aren't really similar.
I don't know - they seem pretty similar to me, in terms of conveying
information etc.
It'd be a better
analogy if the thing representing a value type could be referred to by a
reference type.

Consider, perhaps, instead a library. Books are value types. The card
catalog entries are reference types. You can make copies of the card
catalog easily, and the cards always refer to the same book. But if you
copy a book, you've made a whole new book.

This is inaccurate too, since in reality a single reference doesn't refer
to a value directly, but something that contains a value (either a boxed
value, or a class containing values). But I think it's closer to what's
going on. :)
Hmm... that version doesn't feel quite as close as mine - which is
fairly natural, of course :) The fact that a card is a reference to a
book suggests that the book is actually a reference type, with the
card being the reference itself. That may be what you were saying in
the second paragraph; I'm not sure.

It does show what I said earlier - actually *teaching* the concept is
a good deal harder than merely *learning* it! The experience I had
personally, and one which others have since agreed with, is that
there's a bit of a lightbulb moment where everything suddenly makes
sense.

I suspect that it would take a *remarkably* good piece of writing to
make the lightbulb moment occur for most people reading it for the
first time. It seems more likely to me that the teaching material (of
whatever form) will set the student down a subconscious train of
thought, and they'll get the lightbulb moment later. The best we can
hope for is to set the train in the right direction and not put any
obstacles in its way.

It's a lot easier to do this in an interactive context, of course,
with questions and answers. Whiteboards are particularly helpful :)
The bonus of this is that once this fundamental concept has been
grasped, all kinds of things become *much* easier to explain -
assignment, parameter passing, garbage collection, memory allocation
etc.

I very much agree with that. One way or the other, it's important to
teach the fundamentals correctly the first time. Using wrong descriptions
of what's going on can never help with simpler implementations , and it
always leads to incorrect implementations in more complicated scenarios
(how many times have we seen someone passing a class reference by
reference, because they thought that was more efficient than passing the
reference by value?)
Absolutely. Likewise, how many times have we heard people referring to
structs as "lightweigh t classes" or stating that structs are on the
stack and classes are on the heap. All of these slightly distorted
views on reality are much simpler to clarify with the right mental
model to start with.

Jon
Jun 27 '08 #15
On Apr 18, 3:01 pm, "BlackWasp" <nospam@pleasew rote:
Yup, still can't disagree with you. That's why I made some changes.

Take a look and drop me an email if you like. Won't post the address here
for obvious spammy reasons but drop me a line on the contact form by all
means.
Will have a look tonight. Happy to have a look at your other pages
too, if you'd like - in particular I noticed (on a quick skim a while
ago) talk about "event objects" in your description of events; I had
no idea what you were talking about at that point.

Jon
Jun 27 '08 #16
Feel free. I am sure you will find plenty of typos ;-) You know the way it
is - good luck with the book btw.

--

BlackWasp
www.blackwasp.co.uk
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:9a******** *************** ***********@q27 g2000prf.google groups.com...
On Apr 18, 3:01 pm, "BlackWasp" <nospam@pleasew rote:
>Yup, still can't disagree with you. That's why I made some changes.

Take a look and drop me an email if you like. Won't post the address
here
for obvious spammy reasons but drop me a line on the contact form by all
means.

Will have a look tonight. Happy to have a look at your other pages
too, if you'd like - in particular I noticed (on a quick skim a while
ago) talk about "event objects" in your description of events; I had
no idea what you were talking about at that point.

Jon
Jun 27 '08 #17
Found that reference to event object.

I guess it is a terminology thing (unless I found a differrent reference to
event object). I learned a lot of C# from Herb Schildt's writings and have
stuck with the same terminology (the Law of Primacy again!).

Anyhoo, as I said, feel free to drop me an email - this thread is getting
way too long!

Cheers

--

BlackWasp
www.blackwasp.co.uk
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:9a******** *************** ***********@q27 g2000prf.google groups.com...
On Apr 18, 3:01 pm, "BlackWasp" <nospam@pleasew rote:
>Yup, still can't disagree with you. That's why I made some changes.

Take a look and drop me an email if you like. Won't post the address
here
for obvious spammy reasons but drop me a line on the contact form by all
means.

Will have a look tonight. Happy to have a look at your other pages
too, if you'd like - in particular I noticed (on a quick skim a while
ago) talk about "event objects" in your description of events; I had
no idea what you were talking about at that point.

Jon
Jun 27 '08 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2072
by: Michael Sparks | last post by:
Anyway... At Europython Guido discussed with everyone the outstanding issue with decorators and there was a clear majority in favour of having them, which was good. From where I was sitting it looked like about 20:20 split on the following syntaxes: 1 def func(arg1, arg2, arg3) : function... 2 def func(arg1, arg2, arg3): function...
0
6706
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft Visual Basic .NET version of this article, see 308049. For a Microsoft Visual C++ .NET version of this article, see 310071. For a Microsoft Visual J# .NET version of this article, see 320627. This article refers to the following Microsoft .NET...
11
6604
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on where the job is running, the job runs sucessfully, PDF files got generated, everything is good. If I scheduled the job to run at the time that I am not logged into the server, Access is not able to print to the printer. The error is pretty...
3
2007
by: flat_ross | last post by:
For anyone who is just getting into VB.NET and/or is starting to work with inheritance I would like to point out a potential pitfall. We found this confusion recently when code-reviewing an application. If you have not used the keyword 'Overridable' then read on for sure... If you setup a child class and you want to override a method in your base class, you may see the squiggles under your child's method name. The pop-up/build error says...
7
2583
by: Peter Row | last post by:
Hi, I've started work on my own control some parts of which use standard controls, others I need to draw on my controls surface to get the display output I require, however.... I seem to be stupid or missing the point. I used DrawString( ) as a simple test but I cannot get it to work at all unless I handle my custom controls Paint event.
3
3203
by: Mark R. Dawson | last post by:
Hi all, I am trying to get custom attributes from a property. I can do this if I pass in the name of the property i.e. "Name" to the reflection methods, but if I pass in set_Name which is what the set piece of the Name property gets compiled to, which I am getting from the stack trace, then the attributes are not returned. For example, Class Person has a property called "Name" which has a custom attribute decorating it. Inside the set...
6
3681
by: semkaa | last post by:
Can you explain why using ref keyword for passing parameters works slower that passing parameters by values itself. I wrote 2 examples to test it: //using ref static void Main(string args) { List<TimeSpantimes = new List<TimeSpan>(); DateTime start; DateTime end; for (int j = 0; j < 1000; j++)
19
248287
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect this data is essential to any developer. This article is a basic tutorial on how to user HTML Forms, the most common method of data collection. Assumptions - Basic HTML knowledge. - Basic PHP knowledge. HTML Forms A common and simple way of...
65
3929
by: Arjen | last post by:
Hi, Form a performance perspective, is it wise to use the ref statement as much as possible? Thanks! Arjen
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10507
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10255
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10036
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9092
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7582
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4150
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.