|
Colborne_Greg wrote: I need this
Probably not.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Simon_Whale wrote: would of have
FTFY
new image() { Height = Height }
In one small test, I see that the this. isn't required, but it seems to confuse the debugger a bit. I prefer to use this. just because.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
It does not fail in C#.
class DataObj {
public int Height { get; set; }
}
class Starter {
public static void Main() {
int Height = 23;
DataObj obj = new DataObj { Height = Height };
System.Console.WriteLine("Set to " + obj.Height);
}
}
Compiles without warnings and gives the right answer.
Once again, if you're going to make concrete statements about what is or isn't possible in a language, you need to check whether that statement is accurate first.
|
|
|
|
|
As I have learned but there is no period before either height so now the reader of the code has to guess at the scope of the object
Real genius
|
|
|
|
|
It's pretty obvious from context that one of those is a property name on the object you're setting, and one is a name in the local scope, and that's all the . tells you.
It's no different from public Form Form (or Dim Form As Form or whatever you write in VB) and other places where you have the same word in two different contexts.
|
|
|
|
|
When dealing with multiple languages from multiple teams anything that makes you think twice about it has to go.
|
|
|
|
|
If I could be arsed, I'd find similar classes in Java and show you how anonymous constructors work there too.
|
|
|
|
|
not familiar with Java so that would be great
|
|
|
|
|
Wow.
Dude. If you're going to say something like that, make sure you're exposed to more languages first.
|
|
|
|
|
6 years of school, granted my studies are out of date by 5 years
|
|
|
|
|
"with" isn't particularly unique or interesting.
There's a lot of functionality in a few lines. But you can stack up languages like cordwood that have lambdas, currying and/or templating features that would reduce the footprint of that code far more.
It's awesome to be excited about a language. Lord knows I've spent most of the last 40 years that way. But do yourself a favor, take this post and put it in a calendar item marked 5 years from now and come back and look at it then.
Visual Basic has come a long way since the VB3 days. But it's a very very long way away from winning awards for elegance.
|
|
|
|
|
The unique part about the with; is that it is simple - easy to learn, little if no problems to overcome just by using the structure.
|
|
|
|
|
Nothing against vb, but catching exceptions and then not handling them is epic fail for me, not "beauty and elegance".
|
|
|
|
|
Running through a database there are some times bad records.
I don't want them crashing the program nor do I care at this point what the problem is
|
|
|
|
|
It's just not that elegant to have two separate try/catch blocks that completely hide the error and never handle it. And everything you have there can be done in C# as well.
|
|
|
|
|
the try catches were not suppose to be illustrated as a bonus, and a laziness on my part, but intentional with how my code works
|
|
|
|
|
Actually it just got a lot more credit... Swift is Apple's version of VB.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Swift looks like C# almost exactly
|
|
|
|
|
Of course my comment is tongue-in-cheek, but you must not have looked at Swift hard enough yet.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
No I haven't, I've only seen declaring memory and other basic functions which all were the exact same as C#
|
|
|
|
|
As I frequently say - it's not the tool that is used that's the problem, but the tool that uses it.
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
That's why visual basic is great.
I don't need to hire anyone who thinks they are a programmer.
Its a tool that is easy to train people and allows me to pay them next to nothing.
|
|
|
|
|
Colborne_Greg wrote: allows me to pay them next to nothing
If you had written that from the beginning, I'm sure everone agreed.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
No, for the love of something NO! It makes writing code easier for those that don't write code. It only exists as some one else pointed out (probably) in reaction to Borland's Delphi (Object Pascal) MS needed to make there Basic compiler have similar features to compete! Bad programmers can write bad code in any language, the language makes it easier (VB) compare to another (C#) but they compile to the same byte code, you can't tell the difference!
|
|
|
|
|
People that don't already write code are
-cheaper per hour
-easier to train
-get the job done faster
-get the job done without added flare
-almost half the cost overall as other programmers
-they write in full words (no bad habits)
|
|
|
|