|
Yes. And I really don't like that Extension Methods require the using directive.
Very powerful are aliases though. Recently I used an alias to resolve a namespace conflict, rather than have globall:: scattered throughout some code:
namespace PIEBALD.Data.MySql
{
using MySqlClient=global::MySql.Data.MySqlClient ;
public sealed class DatabaseInfo : PIEBALD.Data.DatabaseInfo<MySqlClient.MySqlDbType>
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Thank God I don't need SQL anymore.
I use Unidex which I wrote in Visual basic
|
|
|
|
|
visual basic takes less skill to get the job done
|
|
|
|
|
If it's in VB, it isn't "done".
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Whats not in visual basic?
|
|
|
|
|
In the time of autocompletion editors, less typing is no longer a valid argument.
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)
|
|
|
|
|
If you'd picked a case of With doing namespace/object elision, you might have a point. But as several people have pointed out, this is an object initialiser which is included in C# and (I think) has been since the same .Net compiler version as the VB.Net syntax you're demonstrating.
Other languages like JavaScript, Ruby, Perl etc can create objects with data in a single statement like this, too, and have been able to for years.
If you're going to make a claim like "no other language can do [something your fave can]" then at least a tiny bit of research would be a good idea.
|
|
|
|
|
Without the with operator C# has a smaller scope
|
|
|
|
|
Sorry as Bob has pointed out, this sort of argument needs more research.
many have also pointed out from the .net framework that C# doesn't need the With keyword. There are many other keywords if you looked and were pedantic enough C# doesn't use but slight change / merge of keywords you could achieve the same thing.
relax and enjoy the lounge they don't really care what language you code in.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
VB
New image with {.height = height}
C#
New image {height = height}
second one fails
|
|
|
|
|
No as you would of written it like this
VB.NET Version
New image With
{
.height = height
}
C# Version, in the C# version the With Keyword is ommited
new image { height = this.height }
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
So now instead of with I need this.
And I would have to write this over and over and over
|
|
|
|
|
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".
|
|
|
|