|
For 'as' try using the TryCast operator in VB. For 'is' you can use the TypeOf operator.
Is that what you mean?
|
|
|
|
|
Johnny J. wrote: If you're a professional programmer, you should be able to code in both
languages with same ease.
Why? While they both target the same CLR, the syntax of the two languages is sufficiently different that while you may be able to code in one fluently, you might find the other more complicated. This has nothing to do with being a professional programmer.
I don't dislike VB.NET, nor do I particularly like it. I am ambivalent towards it - if it had never been created, I wouldn't have felt the need to bemoan it; but similarly I don't feel the need to bemoan its existence. As my background is C/C++, the syntax of C# feels more natural to me, but I fully appreciate that it feels alien to a VB.NET programmer. That doesn't mean they aren't of the same standard as me, it just means they are familiar with a different syntax.
|
|
|
|
|
It seems to me that C# devs should be getting on with coding instead of spending their time moaning about us VB guys.
At the end of the day its the front end that matters to a customer.
Mine is not to reason why. Mine is just to code and cry.
http://www.skillsmaster.co.uk
|
|
|
|
|
What really matters is getting paid. If I get paid the same amount per hour either way to use C# or VB, then I'll keep my preferences (C#) to myself and give the client his money's worth.
When posting here, I do not represent anybody but myself.
|
|
|
|
|
Matthew Graybosch wrote: If I get paid the same amount per hour either way to use C# or VB, then I'll
keep my preferences (C#) to myself and give the client his money's worth.
What you get paid has nothing to do with the quality of the work, the difficulty involved or anything else.
It has everything to do with how good a salesman you are and how dumb the customer is.
I had a friend who was able to bill dBase IV programmers at $120 an hour (in 1996) to generate sales analysis reports. At the same time, my friend with a PhD in Computer Science was eking out $50 an hour from iCompany for writing communications code in C. And every quarter, iCompany would produce record profits and promptly cut his rate to $35 so that the next quarter's results would look even better.
Do you get $120 an hour for C#?
PS. The story is even better. The guy who was doing dBase IV programming sold essentially the same system (with very minor modifications) to 7 different companies in Silicon Valley and so his billing rate was about 7 x $120 ($840) an hour because be billed every company all the development time for the software.
|
|
|
|
|
I sure as hell don't ask for $120/hour to do C#. I save that for when my recruiter says she needs a VB6 developer or somebody who knows bugger-all about RPG or COBOL.
When posting here, I do not represent anybody but myself.
|
|
|
|
|
Had a recent job in which you had to code in VB6 when you know VB.net and C# exist? I did. Getting paid is not all that matters.
|
|
|
|
|
I held a job like that from 2003 until 2009. Never, ever work for family.
When posting here, I do not represent anybody but myself.
|
|
|
|
|
I do love the fact that a bunch of developers including myself read this article and took it seriously, but upon reading it again I noticed this at the top of the article.
Andy ‘Wise Owl’ Brown decided to write a tongue-in-cheek rant whilst he could still remember the pain-points.
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
I'm glad someone noticed.
The reaction from most people in the forum is actually quite worrying
|
|
|
|
|
I sincerely hope checked and the article is satire. If it isn't, the guy's I wrote the following because I'm an idiot:
1. Writing software well is a matter of attention to details. If you can't be arsed to even get the name of something right, you're probably going to screw up more important things.
2. If you're going to criticize a language, at least get your examples right. His C# code doesn't duplicate the logic in his VB.
3. Learn how your IDE works, moron. I can assign events in my C# code any time I like, and I'm using VS2008.
4. These are operators, which I would expect to be concise. Can you imagine writing this:
proportion = openquantity openquantity a addto b addto c addto d closequantity dividedby e closequantity multipliedby 100 instead of
proportion = ((a + b + c + d) / e) * 100 Secondly, programming is symbol manipulation. As in my response to #1, if you can't get this right, there are a whole bunch of other things you won't get right.
5. Sigh. Snippets in the IDE. The guy's like a carpenter who has to be told how to use a hammer every morning.
6. They's in the bloody CLR library. In 30 years of programming, not once have I needed to use the mortgage payment function. As far as 'is number' goes, I do localized applications. The library functions for validating localized numbers are usually inept. The .NET versions are actually pretty good, from what I've seen. They seem to work well for common number formats found in the U.S., Europe, and Asia.
7. VB's line continuation character is as annoying as Pascal's use of the semicolon as a statement separator. It's a special case you have to remember all of the time. At least with the C-style languages, you just put the semicolon at the end of every statement. Period.
8. To-may-toe, To-mah-toe.
9. VB encourages you to be sloppy. Once again, point #1.
10. C# gives you a whole lot more control over data structure transformations. With a language that encourages sloppiness, I wouldn't expect it to handle this kind of thing in a fashion that performed well.
Software Zen: delete this;
|
|
|
|
|
Gary Wheeler wrote: you just put the semicolon at the end of every statement. Period.
Even after a compound statement? 
|
|
|
|
|
Sigh. I thought I felt a petard-wedgie coming on.
Well, at least it's harmless if you do.
Software Zen: delete this;
|
|
|
|
|
Gary Wheeler wrote: I sincerely hope checked and the article is satire. If
it isn't, the guy's I wrote the following because I'm an idiot:
That just earned you a five.
But it means that you're in a minority in this forum.
|
|
|
|
|
I'm really surprised no one else caught this, but his example of "stupid symbols" is incorrect.
C# VB.Net
Test if two conditions are both true && and
Test if one or other condition is true || or
The C# equivalent of "And" is "&", and the the VB.Net equivalent of "&&" is "AndAlso". For a guy who's worried about how often he's going to have to hit the shift key, I'd think he'd prefer these quick symbols to the verbosity of VB.
|
|
|
|
|
That's normal that C# developers thinks that VB is s*it.. it is like C/C++ and C#... C# developers thinks to be cool just because there is a "C" char in the name....
|
|
|
|
|
I can write both languages equally.
I just hate the snobbery that is displayed by some C# programmers.
The differences between the languages is getting slimmer with every version.
As I see it C# is much nearer to VB.Net than it is to C.
There are many things that were in VB long before they appeared in C#.
The article is right, the Visual Studio IDE recompile on the fly and show syntax errors faster in VB than it does in C#.
This is not about the language but it can be taken into account when you choose a language.
This days I work mainly in C# and I enjoy it.
The one thing I miss is the ability to put a property in a ref our out parameter.
VB can do that and C# (at least 3.5) can't.
|
|
|
|
|
Pascal Ganaye wrote: There are many things that were in VB long before they appeared in C#.
And vice versa. There's nothing wrong with this either way; it's good that languages take on positive features of other languages.
Pascal Ganaye wrote: The one thing I miss is the ability to put a property in a ref our out
parameter. VB can do that and C# (at least 3.5) can't.
Are you talking about:
public void MyMethod(string text, out int retValue1, ref int retValue2)
{
retValue1 = 10;
retValue2 = 20;
} If you are, this has been in C# since v1.
|
|
|
|
|
More something like this:
Sub Main()
Parse("5", A)
End Sub
Property A As Integer
Sub Parse(text As String, ByRef retValue1 As Integer)
retValue1 = Int32.Parse(text)
End Sub
Would translate in C# into
static void Main(string[] args)
{
Parse("5", out PropertyA);
}
static int PropertyA { get; set; }
static void Parse(string text, out int retValue1)
{
retValue1 = Int32.Parse(text);
}
The C# compiler doesn't like it though.
Error 1 A property, indexer or dynamic member access may not be passed as an out or ref parameter
For info the vb compiler compiles something like this:
int tmpA = A;
Parse("5", ref tmpA);
A = tmpA;
|
|
|
|
|
I see, although I can't see a situation where I would want to do this.
|
|
|
|
|
I'm lazy, I assume a string came from the user, so I further assume it is screwed up and would use int.TryParse and either throw an error or override it with a default when the string really is screwed up.
("int" because its shorter and exactly the same as Int32.)
|
|
|
|
|
I get two "A property, indexer or dynamic member access may not be passed as an out or ref parameter" as errors from the last statement:
static int val1 { get; set; }
static int val2 { get; set; }
static void MyMethod(string text, out int retValue1, ref int retValue2)
{
retValue1 = 10;
retValue2 = 20;
}
static void Main(string[] args)
{
MyMethod(" ",out val1,ref val2);
How do YOU pass properties as out or ref parameters?
Personally, it makes total sense to me. Properties are an abstraction level that protects the value that stores the actual storage location. out and ref are both asking to have direct access to the storage location. That violates basic principles of properties. I would be EXTREMELY surprised if VB.NET allowed that to happen.
Seems like inexperience in what properties are, that would cause the complaint.
|
|
|
|
|
KP Lee wrote: How do YOU pass properties as out or ref parameters?
Well, I don't. It's not something I've ever really wanted or needed to do as this really doesn't make too much sense from an OO point of view. It runs the real risk of introducing issues as a side-effect.
|
|
|
|
|
Pete O'Hanlon wrote: Well, I don't. Sorry, I knew that you knew this from your earlier response. Poor joke.
We agree on this:
Pete O'Hanlon wrote: ...as this really doesn't make too much sense...
|
|
|
|
|
All of you are missing the main point: Both C# and VB are better than Java.
|
|
|
|