Bjorn Sigurd Johansen
- Please add optional parameters and parameter default values to C#!
Lets talk about this a bit, this has got to be the dumbest thing I have read on this thread. Optional paramters are a freaking nightmare. I am a C#/VB.Net/Java/C++ and yes Delphi developer with 30+ years of experience.
If any VB.Net developer here thinks that optional paramters are a good thing then get out of IT, because you are lazy and should be working at taco bell and having your mommy tuck you in bed at night.
Because you obviously have never written an assembly used by anyone else on your team.
Try this write a dll and put the following in it
public function method1(ByVal a as string) as integer
return method1(a, “I am stupid”)
end sub
public function method1(ByVal a as string, optional b as string =“stupid”) as integer
return 1
end sub
now compile that assembly
and reference it from another and see what comes out.
just in case you are to freaking lazy here are the results
Runtime error:
why because the MSIL was written for you guessed it C# and the method signatures end up being the same. the optional is removed because, uh its optional.
also for all the ByRef people out there, everything is a freaking object so why in the hell do you need to put ByRef?
try this
Module Module1
Sub Main()
Dim s As S = New S()
method1(s)
Console.WriteLine(s.value)
Console.ReadLine()
End Sub
Public Sub method1(ByVal s As S)
s.value = "Apple"
End Sub
End Module
Class S
Public value As String
End Class
wow look at that - s.value was set to Apple
even though we have byval???
C# programmers know that S is a class and s is a pointer to an object so it would be set. I do not know how may times I have had to explain that to VB.Net ex-vb6 programmers. Who have been programming for 10 years.
IMO People who exclusivly program in VB or VB.net are idiots, VB.Net was supposed to go by the way side before VS2003 came out, it was a stepping stone. Hmmm anyone remember J#? What language does Microsoft develop in? C# what langauge are games starting to be written in C#, why because it is a better langauge.
and if code beautification is all any VBer can bring to the table, like, wahhhh “I want my End If to be displayed when I hit enter” then get a life or maybe an add in like Code Rush from dev express and create you own macros, if you cannot figure out how to use the IDE.
And code readablity
why does
If Not a = 5 Then
do something
End If
make more sense then
if (a != 5 )
{
do something
}
is on crack or a vber
and what is up with AndAlso and OrElse -
C# is default for short circuit. why continue processing the conditional if it has already been validated.
Dim ds as DataSet = nothing
If ds isnot nothing AndAlso ds.Tables.Count 0 Then
End if
vs C#
if (!ds ds.Tables.Count 0)
{
}
yeah I know there is some setting somewhere for short ciruiting
but then you have some person come in that only know VB and is wonder why you set it.
I have never used And ins VB it is always AndAlso
last thing about IDE
VBs famous auto compile or auto syntax checker.
Microsoft know there is a bug in it, it causes a machine to lock up and shutdown VS2003 and VS2005.
So Auto Syntax checker/compiler IMO is a waste of my time.
I wonder why C# does not have that feature - maybe trying to annoy anyone from using VB.Net???
Intellisense. C# is so much better
try this in C#
DataSet ds = new
and poof System.Data.DataSet appears
Why can’t Vb.net do this? Oh yeah wait lets use Imports and with statements right??? well sometimes, sometimes in development there are products that may have lets see
Company.ProductName.V1.ClassA
and
Company.ProductName.V2.ClassA
and you need to use both of these in your project or solution of projects (I know VBers, this is new idea multiple projects in one solution, but there it is) and you have to have the whole namespace and class name in the code and the imports will not help you out.
with statements were a bad idea from the begining and are a nightmare in debugging, but oh wait in VB you never have to run a trace or debug, beacause it is a perfect little (I do mean little language) ( BTW that is sacarsm)
and for one last point, for everyone complaining about case sensitive syntax, For the love of God, SHUT UP!!!
There are Standards in coding, and VB just goes along and follows their own little standard. just look at any other real language that has been around for a while and you will see how easy it is to code using casing.
I am so freaking tired of reading someone vb code and seeing
objPerson or oPerson
and when you ask then why use obj or o and they answer because its and object, then you see
Dim I as Integer
and ask why not objI or oI, and they say because that is a value.
I just cringe
So
int i = new int();
must not be possible