Migrate from VB.net to C# [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have been developing applications using VB.net for the past 5 years. As I tried to learn Java earlier and found it very difficult for me I did stick on to VB.net. And for me C# is more or less similar to Java.
Now I cannot get away with it. I have to code on C#. Is there a way I can get to speed with C# fast. I would really appreciate if you can let me know your thoughts and if there are any good resources I can try.

If you have been doing VB.NET for that long then the underlying OOP concepts in that language and your experience with the .NET Framework put you in an excellent position to learn C# quickly. This means all you really need to learn is a new syntax and the best way to do that is to practice.

First, don't panic. The syntax is slightly different, but in my experience, most people that I've worked with who have been developing in VB.Net are able to get over that and get up to speed in a week or so.
The main thing to remember is that they are both .NET,and it's the .NET Framework and the Class Library that do all the work. It's not like Java where you would have to learn a whole new set of libraries. In C#, a System.Text.StringBuilder is the same System.Text.StringBuilder you would use in VB. The learning curve really isn't that bad if you keep this fact in mind.
Plus, if you're using the MSDN library, there are examples in both languages in almost every case, so you can pick up a lot of the differences just by using the examples.

I find language translators useful:
http://www.developerfusion.com/tools/convert/vb-to-csharp/
I am working on a presentation & want to include both VB.NET and C# code. If I don't know how to translate something from C# to VB.NET, I dump the code into the translator and I learn.
I have relearned VB.NET stuff that I have since forgotten. I'm sure that it will work the other way around.

You can try http://converter.telerik.com/ far better than conversion engine of DeveloperFusion.

I think the best way would be probably buy a book on 'Learning C#' ... why? Because its a structured approach.
You'll fly through the book because you already understand programming concepts such as data types, loops etc.
I find Wrox books are great for these topics:
http://www.amazon.co.uk/Beginning-Microsoft-Visual-2008-Guides/dp/047019135X/ref=sr_1_1?ie=UTF8&s=books&qid=1273327223&sr=8-1
Depending how serious you are, you could also purchase the 'Professional' edition by Wrox for more complex parts of C#.
I prefer the book option because its route through the langauage... the only other way would be to keep researching on google/msdn on to find out how to do things in C#... which might get annoying and tiresome.
As others have said, once you have a good grasp of C# you will be able to reopen your older VB.NET projects and actually convert them to c# with ease.
HTH

Actually, if you've been doing VB.NET for last couple of years the transition shouldn't be as hard as you make it out since the language are very similar. You just have to look at the tons of online C# to VB.NET code translators that are available for evidence. Well several years ago when I was porting over VB.NET to C# code the main things it would choke on was arrays since syntax is different enough and case sensitivity since VB isn't case sensitive. Nowadays, there might be more problems though will all the additions they keep adding to C#.

Related

Where to start with C# [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Im a pretty experienced programmer in PHP and mainly web languages but today i have decided i want to start to learn a new language!
Im only 21 and I feel as I will never make it in the programming industry without a great set of languages under my belt, So i decided to have a look at C#.
The reason I have chosen C# is because some C programmers have told me that C# is the best language to learn for desktop applications.
I think i need to get started with the Syntax / Structure of C#, What Development Environment to use, and other things that i might face along my new journey.
I hope somebody can guide me
Thanks.
For IDE, you can use Visual Studio Express. And here's a nice set of tutorials.
Also do get your basic concepts straight about .NET framework and CLR.
Once you get the hang of it, Try out LINQ. It is (arguably)the most wonderful feature of the framework. Find some good LINQ tutorials here and here
Although you explicitly mentioned Desktop applications, .NET FW is equally suitable for Web applications 4GuysfromRolla is my favorite ASP.NET resource.
For Dektop applications you might want to start with WinForms, but WPF is the technology of the future. So you are better off learning it if you want to be developing Desktop applications for windows.
Happy Learning!
Stuff you'll need for the beginning:
Visual Studio 2010 Express edition
Few evenings with coffee and Beginner Developer Learning Center
A nice book like this one (it might be a giant one, but I'm in love with it)
Some more coffee
A lot of patience with stuff that isn't in PHP (LINQ, delegates, generic types etc)
Some nice idea to start actually developing and trying stuff out
The best way to learn is to have a problem to solve, and specifically I mean to do something that you DON'T know how to do, rather than something for which you already have the tools. I'd browse around on the net for some toy problems and try to build an app for it.
Eg. I only started on the way down OOP once I decided I needed a poker probability calculator. So basically I had to read a bunch of stuff about VB 6 as I went along. Classes, properties, methods, syntax... the web is great for that kind of thing.
I suppose what I mean is Just Do IT... (see what I did there? :) You'll screw things up, but learn loads more than any book can teach you.
If you're using Visual Studio for Learning it you can use MSDN that perfect for early learning is enough.
I highly recommend Illustrated C# 2008 by Daniel Solis. That's the book I used to learn how the C# language worked (Don't be fooled by "Illustrated" in the title: it's not so much a "beginner's" book as much as it uses good illustrations to teach the language).
You might consider following up with a book dedicated to Silverlight, Windows Presentation Foundation, or ASP.NET if you want to be able to apply what you learn in C# to an appropriate API. I would recommend any book by Matthew MacDonald for the latter.
Learning the basics Pascal, Java, C# and even C is more or less the same...
Start with the studying material of any academic "Introduction to Computer Science" course,
try solving the assignments in a few different languages (to learn C# at a C-like level),
then move on the material from any academic "Object Oriented Programming" course to learn the rest of the basics.
After that is only a matter of experience and searching the MSDN help.
Since you're already an experienced programmer learning C# is more a less an exercise in learning the .NET Framework. The syntax should be easy enough for you to nail down pretty quickly, just by looking for a few tutorials. The harder part will be learning the vast API available to you via the Framework.
I suggest finding a good book on C# (I've had good experience with Microsoft Press and I've heard good things about Wrox and O'Reilly). Make sure it discusses classes, polymorphism (inheritance and interfaces), event based programming, LINQ and reflection.
I believe you'll also want to look at any books dealing specifically with ADO.NET and WPF. The great thing about .NET is once you learn the .NET Framework API you can pretty much move between languages as needed.

Newbie: should I learn c#, VB.Net or VBA/VB for excel programming? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
My background: Mostly C programming. I have some (very recently...last 2 months) acquired JAVA (novice) skills. All my limited experience is based on developing for linux.
I would like to do some excel programming for work purposes. My main interest is in starting to create "dashboards" and charts/reporting from excel sheets as I'm sick and tired of updating many sheets by hand. I'm lazy so I love to automate wherever I can :-)
Which one of these "new" languages (for me) would you recommend to learn? I'm also hoping that if/when I'm getting more familiar with Windows/MS Office environment I can do more "powerfull" things.
If your main goal is to optimise your Excel tasks, then VBA is the language to learn.
The good thing is that if you have any programming background the learning curve is extremely straightforward.
Just run "Record Macro", perform a task, then look at the code that was generated. You've got a working example to learn from.
I personally prefer C# as a language, but in terms of released versions, VB.NET is a better language to use for Office interop. C# 4 has improved this situation a lot though, with named arguments and optional parameters, ref argument faking and COM PIA linking.
If you can use C# 4, that might be the best option for you - but if you're stuck with fully released versions, you might want to go for VB.NET instead.
If you want to dig straight into excel automation, I'd stick to VBA. If you're more interested in extending your knowledge, I'd choose one of the .NET languages, probably VB.NET.
C# seems to be more prestigious/popular, but it's also closer to what you already know. If you learn the .NET Framework using VB, that and your C/java syntax means you'll be able to read C#. It would also give a smoother transition to VBA if you change your mind.
Since you know Java & C, C# should be the easiest to learn. More jobs for C# skills too, if that's important to you.
All of the answers given are sensible, but I'm not sure they're realistic. Yes, Microsoft have been wanting to get rid of VBA for some time now, and I'm sure they dearly wish that Visual Studio Tools for Office would take off; and yes, VB.NET and C# both support something called classes (using object-orientated programming) much better than VBA does.
HOWEVER ... the world uses VBA! Particularly for Excel solutions, I'd guess about 99% of all systems ever written use VBA. So personally I'd learn VBA, helped by the fact that:
You can record macros to see how to do things; and
It's built into Excel (no need to buy or install any other software).
I've written a VBA tutorial online which I hope will help, full of example code and diagrams. Let me know what you think of it, if you should use it.
PS It might seem that my advice is somewhwat biased, but it isn't. We train on VSTO, C# and VB.NET, and my personal preferred programming environment by some way is Visual Studio (VBA drives me mad when I have to revert to it now). However, that's the result of nearly 20 years of learning! For a new programmer, VBA is much simpler to learn.
Microsoft plans to get rid of VBA sometime in the future. Support was already dropped from the Mac version of Office 2008 for example. It way stay around in the Windows version for some time, but no significant new development will be done on it.
Seeing you have C and Java knowledge, and considering you're starting fresh, I'd definitely go with .NET. It's simply the better investment for your time.
Like Jon Skeet says, C# (4.0) is probably your best option if you don't mind using beta software.

Learning Python for a .NET developer [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I have been doing active development in C# for several years now. I primarily build enterprise application and in house frameworks on the .NET stack.
I've never had the need to use any other mainstream high level languages besides C# for my tasks, since .NET is the standard platform we use.
There are some legacy Python applications that I have been asked to support going forward, I have no exposure to python and dynamic languages in general(although I've done a fair bit of JavaScript).
I was hoping to get some guidance/advise to aid in how to go about learning a language like python for the statically typed mind.
EDIT: Using IronPython is not an option!
Foord and Muirhead's IronPython in Action is an amazingly good book, perfectly suitable for teaching Python to .NET folks as well as teaching .NET to Python folks. I may be biased, as I was a tech reviewer and Foord is a friend, but I've had other cases in the past where a friend wrote a book and I tech reviewed it -- and ended up deciding the book was just wrong and publicly saying so (way to lose friends, but, I just can't tell a lie, not where Python is concerned at least!-)
Edit: If you're forbidden from moving to IronPython (which would probably support your legacy apps just fine, btw), there are better answers: Mark Pilgrim's Dive into Python is often considered the best Python intro for the experienced developer, and my own Python in a Nutshell has been praised as the fastest way onboard for superstar developers. I am of course biased in favor of these -- Mark is a colleague, and my wife was a key tech editor for his book (and my own as well), and obviously I'm biased in favor of my own book too;-). But then, I do tend to be biased towards a lot of the best Python books, as I've either had a hand in their editing, or am friends with their authors, or both;-).
Hardest thing I was confronted to in using python coming from Java was to properly wrap my head around the Duck Typing thing... At first I thought it was just plain horrible and just dressed the hairs on the back on my neck.
Next is the scope by convention, but that one is pretty easy. And the importance of white spaces gave me a few bumps.
However once you ease yourself in the language's concision and speed of development you learn to appreciate it a lot more. After a while I thought it was the best thing that ever happened to me !! :-)
here are a few things that helped me a lot :
First I started with this book and got the basics of the language and for everyday use the Python Quick Reference Card was very helpful. Also the console will be your best ally to try quick things and solidify your learning.
For IDEs, coming from the eclipse world PyDev was a natural choice for me, but there were many more to choose from. But if you are more familiar to the Visual Studio environment the Python Tools for Visual Studio is pretty darn good too.
Good luck, Hopefully you'll find Python as much fun as I did.
There is a big initial hurdle of getting comfortable with dynamic typing. The first step is when you look at Python-code and realize that variables aren't defined anywhere, you just create them out of thin air, which feels like jumping over a cliff. There is a brief moment before your hang glider catches the air properly.
And then it's going to take time before you trust your newfound dynamic wings, and you probably only can get their by doing aerobatics with them. Learn how python handles references, have fun with monkey-patching methods, duck type various animals. Try to learn some ugly tricks.
And although you can't use IronPython for this, there is no reason you can't use it to learn Python.
You're going to experience quite a bit of culture-shock going from C# to the wild duck-typed outback of Python. Lack of types and intellisense can be pretty daunting. Good thing that you're experienced in JavaScript. Also know that indent-sensitive block rules of Python can be very confusing for the inexperience (usually you either love it or hate it :-)
Apart from that the biggest challenge moving from one language to another is usually the framework. Getting to know all the classes and functions Just Takes Time unfortunately.
For an experienced developer learning Python, Dive Into Python is a very good book.
Wesley Chun's Core Python Programming book takes a more "ground up" approach, which may be a little slow for an experienced developer. But it allowed for very easy comparisons of the basic syntax and operators compared to other languages. Wesley's writing style is very easy to read, and his example projects are non-trivial enough to actually be interesting.
The Python Cookbook is an excellent reference for learning to program in a 'Pythonic' way. This book contains hundreds (?) of examples of how to solve common everyday problems with Python. In general, the "Cookbook" series will expose you to the idioms of the language faster than any other book.
Whenever I need to learn a new programming language, I start using it for all the 'daily maintenance' tasks that come up - all the little things that I would normally solve with a shell script or with common unix tools - I start to use the new language to solve those problems. Since you have .NET experience, IronPython is probably a good way to leverage that knowledge while learning Python. Even if you only install IronPython in a personal sandbox...and use it for all your daily busy work coding tasks - that can be a great way to learn the syntax and idioms of Python.
The book Pro IronPython is worth reading too if you have time.
I would recommend just to read a book about it. A book for beginners. It'll contain many stuff you already know but you won't miss anything regarding using a dynamic language. I can point you to Dive into Python, which seems to be very friendly, or The Python Tutorial which seems to be very to the point (that's how I learned).
I would recommend using IronPython to help you learn. It is an implementation of Python on the .NET framework. So you can use/learn Python with access to the .NET class library.
A good place to start is by downloading IronPython and looking at IronPython in Action, which is a very good book looking at Python on the .NET framework.
EDIT: Since IronPython is not an option, disregard this answer. Thanks though.

C# popularity industry-wide or is SO atypical? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I feel I'm a well rounded programmer, I'm comfortable in C# and java (several large projects with both) but I tend to use C++ for most applications when I have a choice. (and sometimes R,Python, or Perl as appropriate..)
But I am astounded to see the popularity of C# here on SO. There are 18500 C# topics, more than C, C++, and java combined. I've never felt C# as having such an impact in the companies I've worked with but the SO popularity of C# is undeniable.
My question:
Why is C# so popular on Stack Overflow? My question is not so much a SO question as a desire to understand C#'s current acceptance/growth compared to C++ and java.
Possible explanations for the popularity:
C# is truly that popular and accepted in industry, it's everywhere!
SO is not typical, it seems to have attracted a disproportionate number of C# users
C# has more questions/confusions that tend to need community help to solve
Microsoft (maybe on its forums?) encourages people to use SO for questions
The first explanation is likely the reason, but I just haven't felt that popularity in the real world!
What's your reason you discuss C# topics here?
I think the founders of SO are .Net gurus. Most of the people who follow their blogs found out about the site, and started coming here. The original user base was probably pretty .Net/C# focused.
I also think that C# is the preferred language in .Net with it's interop and ability to use old C and C++ code. Those familiar with C, C++, and Java can easily get a useful application built and working in C#, and be pretty certain it will run on any system with the proper .Net framework installed.
And, C# sounds cool.
I wrote about the popularity of C# on another thread, but to discuss why it's popular on SO, I'd say others have the right of it. C# is popular here because most of the people who first came to SO did so following Jeff Attwood's blog. That's certainly how I came here.
The thing is, SO really is language neutral, even if it's written in C#. Both Jeff and Joel have programmed in other languages and are hardly bigots when it comes to language; they just chose C# because it really is an amazing language to program in.
Comparing C# to Java and C++, the growth has been astounding. C# when it was first introduced was basically Java with a better GUI library (Win.Forms beats the ever-lovin' snot out of Swing any day, IMO, and WPF is heads-and-shoulders above both) and a few extra concepts, the biggest of which was delegates and properties as first-class citizens. Since then it's grown meteorically, constantly adding newer and better things. The entire concept of LINQ has drastically changed the way I approach iterations; couple that with WCF for contract-based inter-process/computer communications and WPF for a truly amazing way to build GUIs, and you've got a rock-solid language and library.
Hell, WCF alone makes .NET the correct enterprise/SOA choice.
By contrast, Java hasn't released a new version in, what, 5 years?
C# is innovating. Java is stagnating. C++ is... well let's call it "stable", shall we? The newest version, which is dubbed "C++0x" will soon need to be called "C++1x". The features that are planned require so many changes to the runtime that you're almost going to have Java or C# when you're done anyway so why bother?
Finally, to answer your last question, I come here to answer questions about any topic. I mostly prefer to deal with abstract problems rather than language-specific issues, but I'm always willing to help regardless of language. Just because I love C# doesn't mean it's all I know. :)
I think it's a combination of reasons 2 & 3. From what I've seen, C# is not as popular as Java, and it's probably not as popular as C++.
From where I live, most people use Java, followed by CPP, followed by C#.
Is atypical.
C# is very popular but StackOverFlow is by no means a reflect of the industry-wide.
Dup: Why is there such a large percentage of C# questions?
Related: Why does Ruby seem to have fewer projects than other programming languages?
I've mostly avoided C#, because (a) I've got a silly prejudice about that glandular freak of a program loader masquerading as an operating system — I just don't do Windows, and (b) because it's so much like Java that I have trouble keeping them apart in my head.
That said, there's a lot of C# being done, and if I weren't an old crank it'd probably be a good language.
The thing is that C++ is riding without training wheels. This makes it much better for some things — I helped build the AS/400 operating system in C++, bare metal up — but not as good for the sort of application programming most people do most of the time.
I guess that is partly due to people knowing of the site thru Jeff Atwood's blog, and Joel Spolsky's website.
Although their writings are not technology specific, it has a slant towards MS stack and hence the site is popular among developers working on MS suite of tools/languages.
Once the site becomes more popular and gets ranked high in google for questions on other tools, it will have more questions on those topic as well.
It really just depends if you plan on working with windows. If you like Linux or mac better then you probably want to use another language (although you could use Mono.NET). I just use C# because of 3 main reasons:
Easy to learn
Easy to use
Easy to deploy
But if you like a different language better then use it. Right now I'm learning C so that I can help contribute to some of my favourite open source linux apps.

Learning C# help or hinder VB.NET learning [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have just moved job and gone from VB 6 to VB.Net and found the learning jump fairly steep, have more a problem with the object / conceptual side of things .. but getting there now ... but as I was a assembler / C++ 10/15 years ago and was considering learning C++/C# .Net (XNA games library calls my name) but not sure if it would hinder my VB.NET learning .... or should I just get myself certified
I was (back in the day) a VB6 dev, and I would expect it to help. There is a much-commented tendency for VB6 developers to keep writing VB6 in .NET; even just a brief look at C# might help you think about VB.NET as a .NET language, rather than a Visual Studio 6 ancestor.
Of course, you might find (as I did) that you don't want to go back to VB.NET after C# ;-p
But as has already been mentioned - the framework is identical. And with C# 4.0, many of the differences will become even less (with "dynamic" making it easier for C# to talk to late-bound COM, and the named arguments / auto-ref stuff making it easier for typed COM).
There is a lot of drive for converging the feature sets of C# 4.0 and VB.NET in VS2010
To me the biggest obstacle for .NET is learn what is available in the framework. Therefore, if you find it easier to code in C# it will mean you only struggle with one thing instead of two. Once you know the framework it's just syntax really as 95% of the stuff you can do with C# can be done with VB.
Also, C# will force you to write code in a more object orientated manner as you can't fall back to coding in a VB6 style.
'yield return' is an example of something that doesn't have an equivalent in VB9 (there are rumours this is being added for VBX though).
Apart from the fact that a large part of what you need to know is about the Frameworks's libaries learning another syntax that targets the .NET's CLR is useful.
Seeing how another language expresses the same concepts helps you to separate the concepts from the language. This is always useful because the concepts are fairly constant, (for example a shadowed(VB) or hidden(C#) function) whilst different languages use different words to express them.
Understanding the concepts better will help you to utalise them when designing code.
IMX, learning C# helped me with learning VB. It's something about seeing the same concepts expressed in 2 ways rather than just 1.
EDIT: Anthony Jones beat me to it :-)
Well for one thing if your method does not return anything then you have to create a Sub in VB.NET and if it returns anything then call it a Function!
I just switched from C# to VB.NET (client requirement) and am still getting used to its nuisances :(
I would say coding in VB almost takes the OOPS out of .NET
I was also a VB6 developer before switching to .NET. First I tried to use VB.Net but it never felt comfortable so I tried C# and fell in love with it. :-)
There are some differences as noted in the previous replies, there are things you can do in VB.Net that you can't in C# (like indexed properties) and vice versa. But apart from that the differences are purely in the syntax. There are in fact several available translators that will convert C# to VB.Net and back.
So I would recommend you to try out C#. Since you know some C++ it shouldn't be very hard to get the syntax right, and the rest is learning to use the framework.
The only real hindrance learning C# would have to VB is documentation. There seems to be a lot more information out there for C# users and trying to find the VB equivalent syntax of sometimes pretty standard C# can be a pain.
That being said... it never hurts to know alot of different ways to do the same thing.
I agree with Garry, the biggest issue is the API.
The second biggest issue I have personally observed is VB6 developers writing VB6 code in VB.NET. That's a good reason in itself for VB6 developers to learn C# - it forces you to think in .NET style.
As a devoted .Net developer I have worked on big projects in both C# and VB.net. Having seen the strengths and weaknesses of both languages I have found VB to be the most frustrating at times.
The problem is that with VB (depending on your project settings) it will magically perform implicit operations such as casts. This can be helpful sometimes, but in the general case you do not want your code to do something unless you explicitly tell it to (this is how C# behaves, in an explicit manner). I would prefer a compiler time error to tell me I cannot convert from one object type to another rather than a runtime exception in our live deployment.
I have found that this implicit aspect of VB tends to hamper the "VB only" developer's understanding of what is going on behind the scenes. For these people, looking at C# seems to trigger some lightbulbs, where they say "aha!, that must be what VB is actually doing when I perform this operation".
I'd recommend you give C# a try, it'll give you a new perspective and you might find that you really like it.

Categories

Resources