|
0) You probably want to use ref rather than out unless you're somehow calculating the total after the switch.
1) There's no need to assign yQ/zQ twice.
zQ += Convert.ToDouble(Console.ReadLine());
And why not use double.TryParse ? And handle bad input?
2) Pay better attention to the teacher and your textbook.
|
|
|
|
|
Thanks everyone, for your input..I do appreciate it.. I'll try all of the above..
Someone said, I should
* Declare all the variables use - I did declare it, I just gave small snippet of the code.
* No Need to assign yQ/zQ - I'm applying what i've learned, I was unaware I could do something like that.
* Double.TryParse - I'm unfamiliar with that, I only know what my book and teacher, taught us.
* I do pay attention to the teacher and my textbook.
* I cannot change it to a if..else statement.. The requirements for this program is to use switch case.
Again, I do appreciate all of your inputs. Thank You, Very Much!
|
|
|
|
|
Dear friends,
Can someone please Explain me about << and >> operator
and diffrence between | and || operator
and where it can be Used. and some example please
by
joe
modified on Saturday, December 12, 2009 1:35 AM
|
|
|
|
|
Try here [^].
There's nothing left in my right brain and nothing right in my left brain. |
|
|
|
|
|
<< and >> do a bitwise shift in the indicated direction the specified number of places. Think of them like n x 10 and n / 10 in decimal (base 10), but in binary (base 2) so they are effectively n * 2 and n / 2 if shifting by one.
| does a bitwise OR where each binary digit is ORed with it's counterpart. This is the OR truth table for each bit in two values being ORed, the first column is the first value, the second column is the second value and the final column is the result:
--------
|0|0||0|
|0|1||1|
|1|0||1|
|1|1||1|
-------- A logical OR || is the same except it can only operate on a boolean value and returns a boolean, so replace the 0s in the table with false and the 1s with true.
Unless you're doing binary operations then you won't use them every day. One place I had to use them recently is in getting/creating the constituent bytes of a MIDI packet. All 'short' MIDI messages are between 1 and 3 bytes long. An Int32 is 4 bytes so Microsoft chose to place all packets in one Int32. If I use a NoteOn as an example:
1001cccc : byte0 = status (c = channel)
0nnnnnnn : byte1 = note number
0vvvvvvv : byte2 = velocity
As an Int32: xxxxxxxx0vvvvvvv0nnnnnnn1001cccc
So to build this Int32 from 3 bytes status, note, velocity) I need to start with status, then left shift note by 8 bits and velcity by 16 bits then OR them all.
Int32 intStatus = status;
Int32 intNote = (note << 8);
Int32 intVelocity = (velocity << 16);
Int32 packet = intStatus | intNote | intVelocity;
To get the bytes out, a 'mask' is needed and a logical AND combined with a right shift
Int32 statusMask = 0x000000FF;
Int32 noteMask = 0x00007F00;
Int32 velocityMask = 0x007F0000;
byte status = (byte)(packet & statusMask);
byte note = (byte)((packet & noteMask) >> 8);
byte velocity = (byte)((packet & velocityMask) >> 16;
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
modified on Saturday, December 12, 2009 1:38 PM
|
|
|
|
|
Thank you friend...thanks for your replay.
i could not understan your code fully but i got somthing about the operator
thank U
|
|
|
|
|
You're welcome
In case you want to improve your English, it's 'reply' not 'replay' - a common mistake
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Thank You...
|
|
|
|
|
|
Hello Friends,
i am working in a desktop application in VS 2008 using C#. And i am creating some crystal reports against search records. Say i have generate my reports against a Selected Client. Generate crystal report against single client is simple and straight forward.
Now i want to select multiple clients and generate there reports and want to display all of them in single viewer. so i can achieve this?
Second reports will show after the end of first report and will be on next page but in same viewer.
Please help me to achieve this functionality. If possible let me know some sample code for this.
Thanks
Sher Azam
modified on Saturday, December 12, 2009 1:31 AM
|
|
|
|
|
Could you design all of your reports as sub reports?
There's nothing left in my right brain and nothing right in my left brain. |
|
|
|
|
|
actually the number of sub reports can be any that's why i am not preferring it. is there any other solution that i can add multiple reports of same type in single viewer.
|
|
|
|
|
Hi:
As everyone might be aware of Microsoft Multipoint SDK, I have been trying to do a project based on this SDK.
This SDK provides us the capability to use several mice on a single computer(obviously several cursors). Everything is fine, but it has only two controls, namely; Multipoint Button and Multipoint TextBox. Now, what if I need to have my own user control?? Please help me out. I am jus stuck.
Thanks.
|
|
|
|
|
HI,
I have createad a custom control for MultipointSDK for making my game with it
You could visit the post on this link
social.msdn.microsoft.com/Forums/en/mptgen/thread/470ba298-0617-4da4-9ba3-bfa0e359e994
Ok you would get the idea
Good bye
|
|
|
|
|
Hi,
I got this chart object on my UI thread called 'm_ChartControl'
I got a method called AddAnnotations that will be run on a new thread in my Form_Load method.
Inside my AddAnnotation method there is a line of code that do this.
Annotation a = m_ChartControl.Charts[0].AnnotationList.CreateAnnotation();
But m_ChartControl.Charts[0].AnnotationList.CreateAnnotation(); is in the UI thread.
How do i create a delegate to put it here?
I have tried this.
private delegate Annotation AddAnnotation();
AddAnnotation addNewAnnotation;
private Annotation CreateAnnotation()
{
return m_ChartControl.Charts[0].AnnotationList.CreateAnnotation();
}
void cAnnotation()
{
this.Invoke(addNewAnnotation);
}
I changed this to
Annotation a = cAnnotation();
and i get this error
Error 18 Cannot implicitly convert type 'void' to 'Manco.Chart.CF.Layout.Annotation'
|
|
|
|
|
Threading in .NET and WinForms[^]
void cAnnotation()
{
AddAnnotation del = new AddAnnotation();
this.Invoke(del);
}
public Annotation()
{
//This function will be referenced and executed on destination form/control
}
|
|
|
|
|
Hi,
I need to tranfer hex values through UART. But the problem is the default ASCII encoding of the SerialPort omits zeroes and such values (mostly below 0x14). What do I change this setting to in order to receive all values from 0-255 through the port? Please Help.
For ex: 0x55, 0x55, 0x00, 0x00, 0x55, 0x55 comes through to the PC C# app as UUUU
Regards,
Karthik
|
|
|
|
|
If you want to send or receive all possible byte values, then your data isn't text, and you should stay away from all text-oriented methods and classes. So the words "ASCII" and "encoding" do not apply, just use the Read() and Write() methods which deal with byte arrays; they'll handle everything (unless you have set DiscardNull to true).
|
|
|
|
|
@gszakacs : That did it! I set SerialPort.DiscardNull = False and I was able to see all the hex values. I was using code from a previous project where I used 50-50 encoding to transmit data.
Thank you!
|
|
|
|
|
I am very new in multithreading. I tried to read some topics but confused with different synchronization techniques used in .net multithreading like Mutex class, semaphore, critical section, event, wait handle and monitor.
Can any body guide me or can we do online conference or is there any in-depth video tutorial in multithreading ?
|
|
|
|
|
you should pick one forum and stick to it.
|
|
|
|
|
Google is your friend.
No... I'm serious... Google really is your friend.
What are - hey! Why are you pointing a gun at me?!
RUN AWAY!!!!
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Is it possible to write Web Services Applications with Vis 2008 Express edition?
|
|
|
|
|
Hi George,
I haven't used it yet, however there is a separate "Visual Web Developer 2008 Express Edition", next to the C#, C++, VB.NET and SQL Server Express-products.
|
|
|
|
|
Yeah! Tried to install and it says SP1 must be intalled first. Downloaded SP1 and it says will not install on express edition. I have the commercial Vis 2008 coming but just sort of "chafing at the bit" to get started on new project.
|
|
|
|