9 Replies - 8530 Views - Last Post: 23 October 2012 - 09:45 AM

#1 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

If I knew then what I'm learning now...

Posted 08 October 2012 - 04:20 PM

OK, I've finally decided that I'm going to learn the syntax of C#. Hah, pretty easy right? Sure, seeing that I have a lot of experience with VB.Net and they're really comparable. And that I can pretty much read C# source code and write a VB.Net version of said code. Here's the thing though. For all you people asking if you should learn C# first or VB.Net first (posing just those two). Let me recommend C# being your first language. Why? Well it's rules and syntax are very similar to other languages and I get the feeling that in becoming fluent with it that it will make other languages easier to pick up on and learn. Plus, once you get use to the fact that C# is case sensitive (aargh), it will be easier moving to vb because I feel like it's easier to go from being forced to be case sensitive to just make sure you spell it the same ;)

That damn semi-colon is going to be the death of me. Yea, I know why it's there, I just forget to type it and then have to move back up through the code and fix it.

So to keep this from being a rant and more of a discussion, I'd like to hear the thoughts of anyone else who's transitioned to C# from VB.Net and what you were hung up on during the transition. Plus if you had any methods to overcome them quickly or just from more and more programming.

I've decided to take a small program I wrote for work and convert it over to C# just to get use to these hang-ups I'm having.

Is This A Good Question/Topic? 0
  • +

Replies To: If I knew then what I'm learning now...

#2 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4437
  • View blog
  • Posts: 7,712
  • Joined: 08-June 10

Re: If I knew then what I'm learning now...

Posted 09 October 2012 - 07:53 AM

Case sensitivity is a big one. There are actually legitimate cases where you're going to have variableName and VariableName] in the same program (an example could be a private field and its public property) and that flexibility is nice. Also, I cut my teeth on case sensitive languages, so that wasn't an issue for me at all. I guess if I had gotten used to not caring about case, it would have been harder.
Was This Post Helpful? 0
  • +
  • -

#3 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3477
  • View blog
  • Posts: 10,723
  • Joined: 05-May 12

Re: If I knew then what I'm learning now...

Posted 09 October 2012 - 10:17 AM

I always spot people making the transition from VB (not necessarily VB.NET) to C# when their WinForms code is littered with Application.DoEvents() calls.

I spot people making the transition from C to C# when they use Application.Exit() in the middle of a button click handler or a error condition handler.

And I spot people making the transition from Java to C# when they use a chain of if (input.Equals("Foo"))...else if (input.Equals("Bar"))... instead of using a switch(input){ case "Foo": ... }.
Was This Post Helpful? 0
  • +
  • -

#4 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2241
  • View blog
  • Posts: 9,412
  • Joined: 29-May 08

Re: If I knew then what I'm learning now...

Posted 09 October 2012 - 10:29 AM

A big one for some is get used to no default instances of forms.
Getting use to not have XML Literals, and do things the tediously long way.
Getting used the less powerful LINQ Query Statements
From x IN xs Where (x Mod 2 = 0)


Having to hit compile each time to see you've got errors.
Pain in the arse switch statements.
Inferior event handling.

This post has been edited by AdamSpeight2008: 09 October 2012 - 10:34 AM

Was This Post Helpful? 0
  • +
  • -

#5 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4437
  • View blog
  • Posts: 7,712
  • Joined: 08-June 10

Re: If I knew then what I'm learning now...

Posted 09 October 2012 - 10:38 AM

I don't know that the LINQ statements are less powerful, just less implicit, or more verbose, depending on your outlook. You have to explicitly tell it what to select, but that's the only difference I'm aware of. Personally I don't like the statements much, I use the extension methods (since they're a superset), but that's just preference.

C# does have realtime error checking, so you don't actually have to compile each time. If you do, you've got an incorrect setting somewhere.

XML literals are something I dearly wish they would bring into the language. There was a time where all my work was with XML and it would have helped so much. Now I mostly work with JSON, so I just wish .NET had better JSON support in general.

As to default form instances, that's definitely something to get used to. I don't know if I think they're good or bad, I can see the argument from both sides. Having them obfuscates what's actually going on and confuses newbies into thinking that they can always do things like that, even with non forms. But they do simplify simple forms.
Was This Post Helpful? 0
  • +
  • -

#6 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: If I knew then what I'm learning now...

Posted 09 October 2012 - 11:31 AM

Well, most of these points have already jabbed me at least once. I'm thinking I'm going to get a book and work through it. Any recommendations?
Was This Post Helpful? 0
  • +
  • -

#7 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2241
  • View blog
  • Posts: 9,412
  • Joined: 29-May 08

Re: If I knew then what I'm learning now...

Posted 09 October 2012 - 11:41 AM

On that matter of LINQ I was on about the Query Comprehension style.
(Stack Overflow Answer) I need a wash now
How would you do aggregates in C# this way? vb.net can use KEY on Anonymous Types.

Default Form instance are thee worst feature of vb.net as some learners, think Forms are special and not just another class. They don't work well on multiple threads, as they're thread local. So each differents thread treats Form1.TextBox1.Text as different forms, when conceptually, you're are assuming it the same one.

This post has been edited by AdamSpeight2008: 09 October 2012 - 11:49 AM

Was This Post Helpful? 0
  • +
  • -

#8 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4437
  • View blog
  • Posts: 7,712
  • Joined: 08-June 10

Re: If I knew then what I'm learning now...

Posted 09 October 2012 - 11:51 AM

Hmm. I didn't know some of that. Never been an issue for me, because I tend to eschew the query comprehension syntax for the extension methods. I just like the way they work, and since the extension methods are a more complete set than either VB.NET's or C#'s query comprehension keywords, I feel like I can get more done faster.
Was This Post Helpful? 0
  • +
  • -

#9 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3477
  • View blog
  • Posts: 10,723
  • Joined: 05-May 12

Re: If I knew then what I'm learning now...

Posted 09 October 2012 - 12:18 PM

Now that AdamSpeight2008 mentioned XML literals, I recently learned that VB.NET has Date literals when I playing with the Code Golf challenge he posted. Do a lot of VB.NET programmers actively use the Date literals?

Also while tackling that challenge, it was a little disconcerting to see an array declared as Dim s(13) As Integer allows access from elements 0..13, while C# (and all the C like languages) int s[13] will only let you access 0..12.
Was This Post Helpful? 0
  • +
  • -

#10 derrellgore  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 50
  • Joined: 16-September 12

Re: If I knew then what I'm learning now...

Posted 23 October 2012 - 09:45 AM

I would suggest Murach C# books as a good starting place. I am actually in the same boat. VB to C#. The first thing I have notices is you have no lines separating you methods....
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1