简体   繁体   English

开始学习C#的最佳方法是什么?

[英]What is the best way to start learning C#?

I have a little programming experience with vb 6 and vb.net not much. 我对vb 6和vb.net的编程经验不多。 Please tell me the best way to become an expert C# programmer and I know it will take a long time. 请告诉我成为专家C#程序员的最佳方法,而且我知道这将花费很长时间。

Think about how you learn human languages - reading, writing, speaking and listening. 考虑一下如何学习人类语言-阅读,写作,口语和听力。

  • Read code. 阅读代码。 Read articles. 阅读文章。 Read examples. 阅读示例。 When you're more experienced, look at the source code for some projects that you use. 如果您经验丰富,请查看所使用的某些项目的源代码。
  • Write code. 编写代码。 Play with the examples you've read about. 玩弄您已阅读的示例。 Modify them. 修改它们。 Solve problems from Project Euler . 解决Euler项目中的问题。 Think of your own projects then try to solve those. 考虑您自己的项目,然后尝试解决这些问题。
  • Talk about code. 讨论代码。 Blog about it. 关于它的博客。 Tell your friends about it. 告诉你的朋友。 See if you can impress your grandmother with how good your program is. 看看您的程序效果如何,可以打动您的祖母。 Now try to impress your professor. 现在尝试打动您的教授。 Learn how to communicate about programming with different types of people. 了解如何与不同类型的人进行编程交流。
  • Listen to other programmers. 听其他程序员的话。 Many of them have more experience than you and have useful things to say that you can learn from. 他们中的许多人比您有更多的经验,并且有很多可以说的东西可以向您学习。 Learn the vocabulary they use. 学习他们使用的词汇。 Discuss your ideas with them. 与他们讨论您的想法。

Practice. 实践。 Practice. 实践。 Practice. 实践。

Google is your friend. Google是您的朋友。

Start by downloading http://www.microsoft.com/express/ and start programming. 首先下载http://www.microsoft.com/express/并开始编程。 If you don't have a project of your own or something someone else wants done, start looking up popular algorithms and implement those. 如果您没有自己的项目或其他人想要完成的事情,请开始查找流行的算法并加以实现。 Try implementing certain design patterns. 尝试实现某些设计模式。 This way rather then just focusing on syntax your learning a heck of a lot more about programming in general. 通过这种方式,而不是仅仅专注于语法,您将学到很多关于编程的更多知识。

Even though I feel the other answers on this thread already well-cover the bases, in terms of replying to a pretty "nebulous," even "naive," question : I'm going to add another opinion (slightly too long to just be a comment). 即使我觉得此线程上的其他答案已经很好地涵盖了基础,但就回答一个非常“模糊”甚至“天真”的问题而言:我将添加另一种观点(稍长的时间,只是一条评论)。

I respectfully disagree with a few posts suggesting an analogy of learning a programming language to learning a spoken, or written, language. 我恭敬地不同意一些帖子,这些帖子暗示学习编程语言类似于学习口语或书面语言。 SO is not the place to discuss linguistic theory, and its relation to evolution, and cognitive structure, and the work of Chomsky, and Pinker, et. SO并不是讨论语言理论,语言理论与进化,认知结构以及Chomsky和Pinker等人的著作的地方。 al., which suggest not only language learning's "innateness," but also how variation in "endowment" (genetic, and, yes, even "temperament"), and its dynamic interaction with environment, and "developmental windows of opportunity" at which learning can take place at phenomenally accelerated rates, contributes differentially to morphemic versus phonemic competency, etc. 等人,不仅暗示了语言学习的“先天性”,还暗示了““赋”(遗传的,甚至是“气质”)的变化,其与环境的动态相互作用以及“发展的机会之窗”学习可以以惊人的速度进行,对语素能力和音素能力的贡献不同。

But, please allow me just to register the hypothesis that there are many ways in which the analogy of learning a programming language to learning a spoken and written language is more of a "catch-all" that masks complexity, rather than a useful tool. 但是,请允许我提出一个假设 ,即在很多情况下,学习编程语言与学习口语和书面语言的类比更多是掩盖复杂性的“包罗万象”,而不是有用的工具。

On the other hand, I suspect (hypothesis) that a person who has achieved mastery of more than one spoken/written language has, indeed, developed certain cognitive structures and skills that may be "useful" in learning a programming language. 另一方面,我怀疑(假设)一个已经精通一种以上口头/书面语言的人确实已经发展出某些认知结构和技能,这些知识和技能可能对学习编程语言有用。

To my mind the above two paragraphs are not inherently contradictory statements. 在我看来,以上两段并不是天生矛盾的陈述。

imho programming in general is also not analgous with learning mathematics or geometry which build structures up from axioms, or fundamental assumptions, into complex systems that sometimes can be "formally" proven, or validated. 总的来说,imho编程也不会像学习数学或几何学那样繁杂,数学或几何学是将由公理或基本假设构成的结构构建成有时可以“正式”证明或验证的复杂系统。 Of course there are some "rare birds" who start off from Knuth, or Gamma, et. 当然,有一些“稀有鸟类”从Knuth或Gamma等开始。 al. and "Design Patterns," and "work their way down" to the "real world" :) 和“设计模式”,再到“现实世界” :)

My "vote" goes with starting with a good book, and, as Mark Byers suggested , combining that with practice, testing yourself, taking on problems like those on the Euler project Mark mentioned, and, yes, certainly, also as Mark suggests, studying other people's code. 我的“投票”是从一本好书开始的, 就像马克·拜尔斯(Mark Byers)所建议的那样 ,将其与实践结合起来,进行自我测试,解决诸如马克在欧拉项目中提到的问题,是的,当然,正如马克所建议的那样,学习别人的代码。

The question, in the beginning, though, is, imho : how to know which code is good to study . 但是,最开始的问题是恕我直言: 如何知道哪种代码是好书

For me the answer to that is : study the code examples provided by really good books like those by Jesse Liberty, for example : "Programming C#" latest (3rd.) edition from O'Reilly. 对我来说,答案是:研究真正好的书籍(如Jesse Liberty的书籍)提供的代码示例,例如:O'Reilly的“ Programming C#”最新(第3版)。 Note : my understanding is the 4th. 注意:我的理解是第四。 edition is due in March 2010. 该版本将于2010年3月发布。

imho Jesse has an unusual gift as a teacher of programming languages, an ability to "pace" the introduction of material in a skilfull way, to select and present the right examples in the right sequence, and remarkable gifts of clarity in his technical writing. imho Jesse作为编程语言老师有着非同寻常的天赋,能够以熟练的方式“步伐”介绍材料,以正确的顺序选择和展示正确的示例,并在他的技术著作中提供了清晰的出色礼物。

CodeProject articles are a great resource for code examples to study. CodeProject文章是学习代码示例的重要资源。 Look for articles in areas that interest you that have a very high rating by other users, and are specific to C#. 在您感兴趣的领域中寻找其他用户给予很高评价且特定于C#的文章。

The lesser-known book by Liberty "C# 2005 : A Developers's Notebook" is a fantastic resource (also, imho, one of the most fascinating books in terms of graphic design and book structure, ever done in any technical arena). Liberty鲜为人知的书“ C#2005:开发人员的笔记本”是一个了不起的资源(恕我直言,就图形设计和书籍结构而言,imho也是最令人着迷的书籍之一,在任何技术领域都是如此)。 It's a series of "exercises" that I would compare to the idea of "etudes" in music : each exercise demonstrates a topic, challenges you to understand a good example of that topic, and each topic is really something that will be useful in your "real-world" programming. 我将一系列“练习”与音乐中“练习”的概念进行比较:每个练习都展示一个主题,挑战您理解该主题的一个好例子,并且每个主题实际上都是对您有用的东西。 “现实世界”编程。

imho, once you have your "feet on the ground" with a hundred hours or so of study and practice of .NET : fly, don't walk, to the "guru-level" with Jon Skeet's "C# in Depth" published by Manning. 恕我直言,一旦您对.NET进行了大约100个小时的学习和实践,便有了“脚上的地面”:飞起来, 别走了,乔恩·斯基特(Jon Skeet)撰写的“深度C# ”到达“ 大师级”曼宁。 He also, imho, is a superb technical writer who shares with Liberty the gift of selective presentation of material, and has his own special, unique, gift for "stepping out of the book to speak to you directly," addressing the kinds of concerns you are probably thinking about as you encounter more difficult material. 他(imho)还是一位出色的技术作家,他与Liberty分享了选择性展示材料的天赋,并拥有他自己特殊,独特的天赋,以“跳出书本直接与您讲话”,解决各种问题。当您遇到更困难的材料时,您可能正在考虑。 I should note that I feel I am a long way from mastery of the content of this book, which just whets my appetite for understanding it. 我应该指出,我对本书的内容掌握还有很长的路要走,这只是激发了我理解本书的欲望。 There's an element of wit and humor in Skeet's writing that also, in my experience, is extremely rare in technical books. 在Skeet的写作中,有一种幽默和幽默的元素,以我的经验,在技术书籍中也很少见。

Please note : disclaimer : while I have worked as a paid consultant for Addison-Wesley on the technical editing of two major .NET books, I have never worked for O'Reilly or Manning, or received "comp" copies of their books (dammit :). 请注意:免责声明:虽然我是Addison-Wesley的付费顾问,负责两本主要.NET书籍的技术编辑,但我从未为O'Reilly或Manning工作,也从未收到过他们书籍的“比较”副本(该死的:)。

I must, respectfully, disagree with the recommendation of "C# in a Nutshell" by Albahari and Albahari (also O'Reilly; I believe 4th. edition is out now : I have only seen 3rd. edition) above : I think it would be a very inappropriate tool for a newcomer to .NET. 我必须尊重地反对阿尔巴哈里(Albarhari)和阿尔巴哈里(Albarhari)的“简而言之C#”的建议(也是O'Reilly;我相信上面已经有第4版了:我只看过第3版):我认为对于.NET的新手来说,这是一个非常不合适的工具。 On the other hand, when you get to studying Linq : you'll find, imho, that Albahari's website and free version of LinqPad is just the coolest thing ever done for helping you "get into" and explore Linq. 另一方面,当您学习Linq时: 天哪 ,您会发现Albahari的网站LinqPad的免费版本只是有史以来最酷的事情,可以帮助您“进入”并探索Linq。

Good luck ! 祝好运 !

The same way you learned VB6 and VB.NET, no doubt. 毫无疑问,学习VB6和VB.NET的方法相同。 Pick up a book, and start reading. 拿起一本书,然后开始阅读。 There's nothing radically different about it that requires any esoteric approach to learning. 没有什么根本不同的要求任何深奥的学习方法。 Just good old fashioned squatting in Barnes and Noble for a few hours before breaking down and buying a book. 只是好老式的蹲在巴恩斯和诺布尔几个小时,然后才分手买书。 You could also mosey around http://msdn.microsoft.com/en-us/vcsharp/aa336809.aspx and read up a bit. 您也可以在http://msdn.microsoft.com/zh-cn/vcsharp/aa336809.aspx上浏览一下,然后阅读一些内容。

If you've already been using VB.NET, C# should come pretty natural to you. 如果您已经在使用VB.NET,则C#对您来说应该很自然。 The syntax will be different, but the objects, methods, etc will all be familiar. 语法会有所不同,但是对象,方法等将都是熟悉的。 Check out the tutorials on MSDN for C# too: http://msdn.microsoft.com/en-us/library/aa288436(VS.71).aspx 也可以在MSDN上查看有关C#的教程: http : //msdn.microsoft.com/zh-cn/library/aa288436(VS.71).aspx

Oh, and welcome to StackOverflow! 哦,欢迎来到StackOverflow!

If you're already familiar with other programming languages, the O'Reilly "In a Nutshell" books are generally a good place to start. 如果您已经熟悉其他编程语言,那么O'Reilly的“简而言之”书籍通常是一个不错的起点。 "C# in a Nutshell" is both a good introduction and a good reference. “简而言之C#”既是很好的介绍,也是很好的参考。

下载Charles Petzold的.NET零本书,并从头到尾阅读它,即使您认为您对某个特定领域有些了解,也不要跳过任何内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM