|
The get and set will always have to have the braces. But
the real problem here is that if the code after a if or what ever
is more than one line then anything after that will not be run.
public string Name
{
set
{
if ( m_name != value )
m_name = value;
m_name.Validate;
}
}
That is why I do like you do because it makes the more readable
and the intent is clearly there. I have seen code that has this
kind of style thru out and it is hard to read.
public string Name
{
get
{
if ( m_name != value )
{
m_name = value;
m_name.Validate;
}
}
}
Bo Hunter
<marquee behavior="alternate">Bo Hunter
|
|
|
|
|
It's not about C# but rather about reading: if You can read using "quick" method (I don't know about it's name in English) e.g You can see all the page (screen) (impossible to remember) the easier way is:
if(...) ...; else ...;
get { ... };
But if You use "standard" method (You can see only few letters, but have better memory) the better way is:
if(...)
...;
else
...;
set
{
...
}
So - Dijkstra, Kerningham etc. couldn't read with "quick" method. It's all. Sorry for my language.
Hi,
AW
|
|
|
|
|
Hey, I am creating an alarm clock in c#. I want to create a event that calls a method to , lets say tell the user what time it is. I tried to read all tutorials on events and delegates. Still, I have no idea how to implement things. can anybody show me a very simple example?
"To teach is to learn twice"
|
|
|
|
|
public delegate void TimerEventHandler(object sender, TimerEventArgs e);
public class TimerEventArgs : EventArgs
{
}
public event TimerEventHandler TimerRing;
protected OnTimerRing(TimerEventArgs e)
{
if(TimerRing!=null) TimerRing(this,e);
}
private void TimerRung(object sender, TimerEventArgs e)
{
}
AlarmClock.TimerRing+=new TimerEventHandler(this.TimerRung);
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
I will submit a complete tutorial in next 1 or 2 days.
I will completely clarify them from scratch.
So, hold on just 1 or 2 days
Thanx
Don't forget, that's Persian Gulf not Arabian gulf!
|
|
|
|
|
Go to help search in your .net IDE and search for "AlarmClock". Microsoft created a tutorial on it.
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
I'm currently using ODP.NET (Oracle Data Provider) to connect to an oracle database. Is there a replacement control for ADODC (to go to the previous and next records) or do i have to create buttons myself for the navigational purposes?
|
|
|
|
|
create the buttons and modify the BindingCOntext.Position property
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
private bool switchMC=true;
private void mButton(object sender, System.EventArgs e)
{
Button btn = null;
if(switchMC==true)
{
btn=(Button)sender;
btn.Text="1";
switchMC=false;
}
else if(switchMC==false)
{
btn=(Button)sender;
btn.Text="0";
switchMC=true;
}
}
I'm not sure if I'm giving enough information here...
When I run this, it takes 2 clicks to get the else if statment to run...
How can I get it to 1?
/\ |_ E X E GG
|
|
|
|
|
Hmmmm, just remove the "else"?
Regards,
Alvaro
If you want to get to the top, prepare to kiss a lot of bottom. -- despair.com
|
|
|
|
|
Your code works fine here, on loading the button text is whatever is has been set to in the designer, on the first click the text changes to "1", then next click it changes to "0", then to "1" and so on and so forth..
I'm not sure what it is you want to achieve, but if you wanted the button text to be "1" before clicking it, you would need to invoke your button click event handler somewhere beforehand, for example:
mButton(this.button1, null);
|
|
|
|
|
Sorry, I didn't explain enough...
There are 7 different buttons that use that method.
They all start out at 0.
Now, try the code out and see what it does... It's rather hard to explain...
/\ |_ E X E GG
|
|
|
|
|
Well, the thing is...
try it with 7 diffent buttons which all use mButton for their on_click...
It get's weird results... just try it out real fast...
/\ |_ E X E GG
|
|
|
|
|
Is your btn.Text initailly set to "1"? You have the initial value of switchMC as true, so the first time through it will go through the "True" condition and the next time it will go through the "False" condition.
Also, you do not need the second "IF" since you are using an ELSE, the ELSE will only be reached if switchMC is not true so you do not need the addition test. You could also restructure the code to either:
Button btn = (Button) sender;
if(switchMC)
{
btn.Text="1";
switchMC=false;
}
else
{
btn.Text="0";
switchMC=true;
}
Or
Button btn = (Button) sender;
btn.Text = switchMC ? "1" : "0";
switchMC=!switchMC;
Rocky Moore <><
|
|
|
|
|
I have 7 buttons that use the code for their on_click...
they are all initially set to 0...
/\ |_ E X E GG
|
|
|
|
|
What is the result your are looking for? You have one state flag which toggles to true or false. Don't you want an array of state flags so you have one for each button?
If that is the result you want (the state of the clicked button to toggle, then you would want to check if the btn.Text = "0" and if so then change it to a "1" and visa-versa:
Button btn = (Button) sender;
btn.Text = btn.Text=="0" ? "1" : "0";
Rocky Moore <><
|
|
|
|
|
YOU DID IT! YoUR A GENIUS!
/\ |_ E X E GG
|
|
|
|
|
really switch it to false.
or add while(true){... code ...}
and it will run forever. a good trick eh Mom
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Please I need the code to access the main thread or at least a pointer. get it.
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Check my reply to your TreeView question.
|
|
|
|
|
thanks
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
There is an Array.Sort() function that sort one dimensional array. How can I sort two dimensional based one of dimensions?
Mazy
No sig. available now.
|
|
|
|
|
yeah extend the class and write your own algorithm for it. Arrays in .NET suck, they should have grabbed some more java ideas
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
How can I get the KeyDown event to fire for the arrow keys?
|
|
|
|
|
you have to override the IsInputKey method, so that it returns true with the key arrows.
protected override bool IsInputKey(Keys key)
{
if (key.KeyCode == Keys.Up) return true;
else if (key.KeyCode == Keys.Down) return true;
else if (key.KeyCode == Keys.Left) return true;
else if (key.KeyCode == Keys.Right) return true;
else return base.IsInputKey(key);
}
Another Post by NnamdiOnyeyiri l Website
|
|
|
|