简体   繁体   中英

Start learning C# without knowing C?

是否可以直接跳到C#,只知道一点C(只是一些基础知识),甚至可能不知道C?

C# and C are very different, they share syntax but the style of programming is quite different. It wouldn't hurt learning C but if your target is C# then start with that.

Learning C will teach you more about how a computer works and give you a low level understanding. C# is a high level language with a lower learning curve to get a graphical interface.

Joel and Jeff frequently discuss the value of learning C, stackoverflow podcast #2 is one example

Yes, the C programming language is not a prerequisite for learning C#. Knowing some C will definitely help you get up to speed on C# syntax but beyond that there are few similiarities.

Sure. C# borrows semantic conventions from C but there's certainly no requirement to learn it.

In fact, you'll skip the phase where you're trying to use C# as though it were C.

If your goal is to learn your first language, and you aren't going to become a serious programmer, by all means learn the language you're going to use.

If you are going to become a serious programmer, you really should get proficient in C sometime. I don't know which way would be harder, starting with C# or starting with C. C will be challenging no matter when you approach it.

If you already know some languages, just not C or C#, go for C# now and pick up C later.

The key is that C is a simpler language, but getting significant things done in it requires more complicated structures. Some things you can easily do in C# will be difficult in C, although C is the more widespread and versatile language.

Certainly. C# uses a C-like syntax, but I think that you will find it to be easier to learn than C.

I'm going to be repeating a lot of answers here, but I wanted to say something in a more specific way than other people have said.

I think it's just fine to jump into C# or any other object oriented language as your first language. In fact many people argue that an OO language should be your first language if you want to become good at OO because you won't be stuck in procedural thinking.

That being said, good programmers that don't have at least a decent working mental model for what is happening under the covers are few and far between. This means, eventually you should learn how a computer manages memory, pointers, how a CPU executes instructions etc... Eventually reading through a C book and an Assembly book would be a good idea IMHO. I don't think you need to become proficient at either; you just need to come to a basic understanding of how the the computer and programming languages work.

虽然C是一般学习的好语言,但我不相信你会得到任何有助于你学习C#的具体知识。

My question would be are you trying to choose a first language to learn programming? (C# being an option) or do you know another language and think you might need to learn C before C#?

If you aren't trying to learn programming, then I would say you can skip C and go straight to C#. But for a first language, I would advise neither. Try for a scripting language that you can really writing code quickly.

Yes. When I started with C#, I had no experience with C.

One thing that many new programmers fail to mention is what do they want to make? Do you want to make something simple like hello world? Or are you looking to make something more complex like a GUI application or a video game?

The reason this is important is that not every programming language is appropriate for every task. As others have mentioned, C is a great systems and driver language (or really anything that requires low level interfacing or extreme performance), and C# is designed to build desktop applications ranging from text editors to huge multi-tier enterprise solutions. Despite the names of these languages, they really only share a similar name and a few pieces of syntax in common.

I would recommend starting with C# and save C for later. You can start working quickly with a lot of free tools such as Visual Studio Express C# . If later you want to start working on stuff like the Linux kernel, compilers or hardware drivers you can quickly pick up C. C is still a worthwhile language to learn.

是的,这很好。

It's certainly possible.

Knowing other languages is always helpful - if only because you've been exposed to the programming way of thinking - but not essential.

像我一样,如果你急于学习新语言,请直接进入。但如果你有很多时间(学生),我想每个想要被称为编码员的人都应该知道C.

Sure! C# is a much higher level language than C, and it handles a lot of the details for you.

One recommendation though, C# is a very good language, but it comes with a slightly steeper learning curve than VB.NET. VB.NET IS NOT Visual Basic, it just carries over some of the syntax.

VB.NET's syntax and keywords are easier to learn and can then easily be translated to C#. Aside from special-cases there's very few things that one language can do that the other can't, and since VB.NET is easier to learn I'm a huge proponent of using it as a "welcome to .NET" language.


Just to clarify: you shouldn't carry the stigma's of "Classic" VB over to VB.NET, VB6 and VB.NET are entirely different languages and frameworks with only superficial resemblances.

VB.NET offers a few niceties for new developers:

  • let nit-picky syntax. C# can make a green developer pull their hair out because they forget ()'s on a void, or added them to a property.
  • Visual Studio offers quick feedback on non-compilable code
  • VB.NET uses words in places where C# uses symbols. In the below examples not that C# expects you to know that ":" means either "Inherits" or "Implements" depending on the argument that follows, VB.NET says "Inherits MyBaseClass" and "Implements INamedObject", which is much more intuitive

To be fair, there is one major gripe I have with VB.NET's default code templates--they don't have the "Option Strict On" and "Option Explicit On" statements at the top. If you get into VB.NET be sure to add these to every class, they'll let the compiler do more proactive error checking and result in higher quality code and understanding of .NET's Type system

To offer an example of equivalent .NET code written in C# and VB.NET:

C#

interface INamedObject
{
    string Name { get; set; }
}

abstract class MyBaseClass
{
    void PrintType()
    {
        Console.WriteLine(this.GetType().Name);
    }
}

class MyConcreteClass : MyBaseClass, INamedObject
{
    public MyConcreteClass()
        : base()
    {
    }

    public string Name
    {
        get;
        set;
    }
}

VB.NET

Option Strict On
Option Explicit On

Interface INamedObject
    Property Name() As String
End Interface

MustInherit Class MyBaseClass

    Sub PrintType()
        Console.WriteLine(Me.GetType.Name)
    End Sub

End Class

Class MyConcreteClass
    Inherits MyBaseClass
    Implements INamedObject

    Public Sub New()
        MyBase.New()
    End Sub

    Private _Name As String
    Public Property Name() As String Implements INamedObject.Name
        Get
            Return _Name
        End Get
        Set(ByVal value As String)
            _Name = value
        End Set
    End Property
End Class

If you aren't an educated OOP programmer, likely it's best to avoid C (or even C++) unless you are a big fan of self-loathing. All of the other stated reasons are valid, but keep in mind that C# is also managed (look that up), so it's far more difficult to get in 'trouble' with .

It should not be a problem. As long as you grasp object-oriented programming, you are good to go.

My answer to all the questions of the form "Should I learn language X or Y? Should I learn Z before Y and X after Y?" etc is the same: Don't worry about such questions. Forget them. If you think learning C# is going to be more useful now (maybe there are more jobs, or maybe you want to join a project, or maybe you are just curious), then sit down and start learning.

If you are already good at one language, it does not take much time to pick up enough of another one to see if you can be productive using it. And, you cannot decide if you should expend a lot of time learning a language well without being familiar with it. Therefore, start studying C# if you feel like it.

To take this to a bit of an extreme, I think the fact that, about 30 years ago, I learned Z80 assembly even before learning BASIC has helped me immensely along the way. However, I would never recommend that you should not learn any other languages until you have mastered assembly. (By the way, all I remember is that opcode 0xc9 is RET ).

So, do start learning C#. If you are curious, continue studying C as well, all the while remembering that even though both have curly braces, they are drastically different languages. Just like C and C++ are.

Learning C or C++ would be more difficult, but you'd probably become a lot more accustomed to the basics, which is never a bad thing.

That being said, I'm not sure about "advisable", but it wouldn't be "wrong"...more a matter of preference.

I found that learning Java for most OOP is most beneficial for learning C# as they are almost identical in libraries and syntax.

A knowledge of C or C++ only becomes useful once you begin diving deeper in C# into areas such as unmanaged code.

C ++和C#之间的相似之处在词法分析器中结束。

不妨阅读K&R的“ C编程语言 ”,因为它是一个快速阅读,它将为您提供一个背景,可以帮助理解垃圾收集语言中幕后的性能。

Sure C# is easier to understand. Of course, knowledge of C would help but if you don't know C then its better to start from a higher level language as C#.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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