|
|
Keith Barrow wrote: Which do you think is better? "I don't care" when I read it.
Both are readable. You're even allowed to do #1 without the { }, as long as you properly indent. And please, omit the comment - it's useless. I've switched to yoda-conditions, but then you could argue that I'm "hurting" readability.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: You're even allowed to do #1 without the { }, as long as you properly indent.
that's really unreadable for me don't do this
For me form ?: is accurate if for some reason you have deep nesting, so you can avoid your code getting more complicated to read.
mm
|
|
|
|
|
Member 9957753 wrote: that's really unreadable for me
don't do this One learns to recognize them fast enough once you're in a project with a lot of developers that aren't all up-to-date on the coding-"rules".
Member 9957753 wrote: For me form ?: is accurate Might be totally unreadable to someone else. The compiler OTOH doesn't care.
I'm with the compiler - as long as it's correct and obvious, fine, do whatever you like. The inline-if is nice for choosing between variables, but not if you're going to put a lot of code in there. If there's a lot of going on, I'd rather see a complete if-else where I can jam some breakpoints in.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Option 1 was a cut'n'shut of the original code, I'm removing the braces. The comment was added by me for the purposes of the post, really to indicate there is logic going on after the bit I'm interested in.
I used to use Yoda conditions as a matter of course during the brief period I used c++. Obviously the c# compiler throws out a warning if you do this, and left to my own devices I keep these down to 0.
“Education is not the piling on of learning, information, data, facts, skills, or abilities - that's training or instruction - but is rather making visible what is hidden as a seed” “One of the greatest problems of our time is that many are schooled but few are educated”
Sir Thomas More (1478 – 1535)
|
|
|
|
|
Hi,
I am new to C# and trying to learn it by doing projects.
I have a situation where data from ms access is to be shown in datagridview combobox.
Suppose, I have table TYPEMASTER with the columns typeID and typeDESC. And I have Datagridview with 2 colums - One Combo Box and another text box. Datagridview combobox is to be populated with typeID, so that once typeID is selected, corresponding typeDESC will populate in the second column of datagridview.
|
|
|
|
|
srinibdvt wrote: I am new to C# and trying to learn it by doing projects. ..and what have you done to try this? Where are you stuck?
srinibdvt wrote: Suppose
Well, it's possible. Have you worked with a grid before? Do you know how to fetch data?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I don't see the need for a gridview there but regardlesss, for the TextBox to populate when the ComboBox selection changes you will need to write code for the ComboBox's SelectedIndexChanged[^] event.
Follow the example in that page, see what it does, and then see if that's what you want to do, if it is come back here and tell us, if its not, come back and ask further questions, showing what you've done
If you think you can do a thing or think you can't do a thing, you're right - Henry Ford
Emmanuel Medina Lopez
|
|
|
|
|
|
There are many reasons for differences in speed on different systems; it is not a valid comparison.
Use the best guess
|
|
|
|
|
The person who makes the comparison is working in a famous non profit server organization and sound like he knows what he is doing.
|
|
|
|
|
Then maybe you should go and talk to him. This sort of question is not really appropriate for these forums.
Use the best guess
|
|
|
|
|
This is an objective question if we comparing these with the same hardware. Latest Java+linux, latest windows+c# are two objective objectives that can be tested and compared with measurable speeds of specific tests.
|
|
|
|
|
That may be, but this is still the wrong forum for this type of discussion; try the Lounge[^].
Use the best guess
|
|
|
|
|
people from lounge saying they don't talk about this kind of serious programming topic over there, they prefer to talk something else like drinking. Check out the replies over there of one of my posts.
|
|
|
|
|
|
How can this has nothing to do with programming when we are discussing which is faster? Speed is extremely important for a programming language, if not c++ would not even exist.
|
|
|
|
|
crunchor wrote: How can this has nothing to do with programming Because you have not asked a programming question. You are talking about some benchmark results that are posted on another website, so go to that website and discuss it with the people who can help you. If you have a proper programming question then this is the place for it.
Use the best guess
|
|
|
|
|
This is a forum of C# in general, not just "C# syntax".
My question is a specific question directly related to C# with possible objective answer.
|
|
|
|
|
crunchor wrote: My question is a specific question directly related to C# with possible objective answer.
Seeing as we are aruging the toss, it isn't. The code may be written in c#, but this is compiles into an intermediate language, CIL. The comparison really compares the speed of CIL execution against Java's JIT compiled (I assume) code. A more accurate description would be a comparison of the performance of the frameworks. You could have tested using VB.net in place of c# and the results would more than likely have been near identical, because it too compiles to CIL.
This really isn't a programming question, you are asking about the speed comparison of two frameworks. The code is a black-box from this point of view and its only relevancy is whether it is a fair and representative test.
“Education is not the piling on of learning, information, data, facts, skills, or abilities - that's training or instruction - but is rather making visible what is hidden as a seed” “One of the greatest problems of our time is that many are schooled but few are educated”
Sir Thomas More (1478 – 1535)
|
|
|
|
|
You describe well but this is still a question strongly related to c#. As I said before, this forum should be topics about C# but not only C# syntax.
|
|
|
|
|
crunchor wrote: My question is a specific question directly related to C# with possible objective answer. Sorry but it isn't. Your question is about the relative speeds of different languages on different systems, and there is no definitive answer. Some combinations of systems are sometimes faster than others; that is all that can be said with certainty.
Use the best guess
|
|
|
|
|
variable E is the hardware, which is a constant
A is C#, B is latest windows like windows 7 64bits ultimate. Combine to run a script in constant E to have a speed number
C is Java, D is a popular linux Ubunut 64 bits. Combine to run a 99.9% similar script in constant E to have a speed number
These two results can be calculated, and the result must have 99.9% confidence level to believe even the script would have 0.1% different.
A and C are programming languages and both are directly in formula, so discuss in either java or C# forum perfectly make sense.
If the graph is based on same machine, and very likely it is, the conclusion is Java+linux is faster than c#+windows, but it is hard to directly compare Java and C# since those have very different speed in different OS.
This is the conclusion already, my question is WHY and HOW.
|
|
|
|
|
We have ALL explained, and you just don't seem able to understand a simple point. The issue has nothing to do with Java or .NET. It's down to the operating system. I'm really not sure how many different ways we can tell you this before you get the point. You seem to fixate on one thing and aren't prepared to listen to answers that contradict that point. The conclusion here is that a program running on Linux outperforms a program running on Windows.
The only way to do a comparison would be to test a program that directly compiles down to an executable on both platforms, and see how they compare. And no - your question has nothing to do with C# - that's only one small part in this equation.
|
|
|
|
|
then why c# is much slower than java in linux? The link has this result too. As i just said, it is os+language, not just one of these.
|
|
|
|