Good exercises to transition from coding in VB.NET

2020-04-07 07:04发布

What are some good exercises that an intermediate/advanced VB.NET web programmer should to do gain syntax chops on C#?

I imagine some good examples would be:

  • algorithms or project exercises that run the gamut of C# syntax
  • reference material
  • list of the key syntactical differences that VB.NET programmers should be aware of

标签: c# vb.net
10条回答
一纸荒年 Trace。
2楼-- · 2020-04-07 07:14

If you have a basic grasp of the language, I would recommend working through project Euler (http://projecteuler.net/) in C#. It starts out very easy and slowly becomes more and more difficult, requiring you to learn more about the language [you are using to develop the solutions] in order to solve the problems.

It may make sense to pick up a C# reference book, if you haven't already.

I think you will be surprised how quickly you transition.

查看更多
我欲成王,谁敢阻挡
3楼-- · 2020-04-07 07:15

this should take care of #3

Comparision

查看更多
家丑人穷心不美
4楼-- · 2020-04-07 07:25

Because programming in .NET is more about the Framework than any specific language or syntax on top, the MSDN documentation is invaluable for crossing over C# and VB.NET barriers because it contains one-to-one samples of using C# and VB.NET syntax for .NET common elements. For example if you look up delegates you will find the same sample in both syntaxes.

For syntax-specific elements other people have posted some good sources.

查看更多
仙女界的扛把子
5楼-- · 2020-04-07 07:27

Play with your own code using an automatic converter.

It should work fairly well for most things. You'll mostly just need to figure out how to rework lambdas and some other situations like that.

Reflector is also very good to help you figure out how to play with converting your code.

As for learning the differences, see MSDN's white paper on this. It's a bit out of date, but a good starting point. A more complete, but less textual reference-like comparison, is available here.

查看更多
在下西门庆
6楼-- · 2020-04-07 07:28

I think best exercise would to build something for yourself.

This way you can to define your scope, to "negotiate" new features and to write new code just for fun.

You could also to solve again problems you already know; for instance, I recommend trying to solve some problems from Project Euler in C#.

查看更多
该账号已被封号
7楼-- · 2020-04-07 07:28

Look up the very basics (how to define a function, how to define a variable), then start coding C# in a real project. Look stuff up once you get stuck (or try the automatic converters mentioned in another answer). The differences are not large, so it will not delay your project significantly. Since there is (almost) a 1:1 correspondence between VB.NET and C# code, it's usually okay to "think VB.NET" and then write your code in C#.

After you are familiar with the syntax, google for the differences between VB.NET and C# (i.e. what can you do in C# that won't work in VB.NET -- e.g. anonymous methods) and rework those things where C# allows for a more elegant solution.

查看更多
登录 后发表回答