Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

I need C# Advice

Discussion in 'Scripting' started by BCrisos, Jan 15, 2015.

  1. BCrisos

    BCrisos

    Joined:
    Jan 8, 2015
    Posts:
    52
    Hello everyone,

    I wanted to ask the community for some advice on C# programming and what would be a good way to start. Currently I'm having issues trying to code at a steady pace since learning syntax for me has been a storm and I cant really find a good beginners guide out there that teaches me what the little things Ex: ( *, =, ==, or *= ) means. Although I've done a couple of unity scripting tutorials and kinda understand some I still have some troubles breaking apart certain code to understand what it does and how it functions. For example I've coded my first 2D character movement script by following the unity live training 2D character controls, which feels as if i cheated since well i didnt do it completely on my own. And when i flip my character to the left he warps left outta place. I only code several hours a week or when ever i can, And I'm an artist trying to learn programming.

    Any advice or tips that may help?
    Should i learn C# the language before Unity C#?
    Or is it the same?

    Thank you guys! I'll be looking forward to hearing all of your opinions, advice, & tips!
     
  2. draxov

    draxov

    Joined:
    Jun 2, 2012
    Posts:
    26
    The Microsofts version of .NET C# similar to Unity's, which is Mono C#, C# uses the equivalent of .NET 2/3.5, you can see the comparison of .NET and Mono here http://docs.unity3d.com/412/Documentation/ScriptReference/MonoCompatibility.html

    Learning the C# language in general is a good way to go, the syntax is the same between Mono c# and .NET c# as far as I know. Looking at code examples and finding what you don't understand and searching on the MSDN for it is a good way to learn the syntax. I don't know any specific tutorials, but I did follow a few, when I learned it I just did a lot of googling when I came across something that I didn't understand, and you could also post in this forum and I'm sure someone will help :)
     
  3. BCrisos

    BCrisos

    Joined:
    Jan 8, 2015
    Posts:
    52
    So if I were to look up lets say some coding when it comes to the syntax in a site like this that is completely unrelated to unity, http://www.tutorialspoint.com/csharp/csharp_basic_syntax.htm

    Will I be able to use the concepts I've learned from that site and use its code effectively in unity? Or is the MSDN site a better source for learning programming, because It'll help a lot to know that I can go to other C# sites when theres something I dont understand in the syntax and learn from it like an example is what this sign means ( // ). Little things like that Is what I dont want to miss out on, since most of the unity script tutorials skip most of the smaller details.
     
  4. kdubnz

    kdubnz

    Joined:
    Apr 19, 2014
    Posts:
    177
  5. draxov

    draxov

    Joined:
    Jun 2, 2012
    Posts:
    26
    Yes you should be able to do that, eventually you'll probably come across a namespace that won't work with with unity because it's not .NET C#, but most things do work. That syntax link is completely 100% relevant to Unity C#, so that's a good starting point. I use the MSDN all the time, it's very useful.
     
    Kiwasi likes this.
  6. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,184
    For the symbols, this list contains every single one in C#, and a page that shows what they do. Like the rest of MSDN, it assumes some technical knowledge; it tells you that the ^ symbol "computes the bitwise exclusive-OR of its operands", but doesn't go into detail about what that means.
     
  7. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    There is no such thing as Mono C# and .NET C#. It's just C#. Beginners often confuse language and framework. .NET and Mono are frameworks (or runtimes if you prefer). The code you write in C# is compiled against a runtime. You can write C++ code for .NET - or VB code for .NET.

    When folks talk about specific features not being available in the context of Unity it's because they are missing from the runtime, not from the language. Until *very* recently .NET was exclusive to Windows and XBox (and for all intents and purposes still is). Mono is an initiative to create a cross-platform version of .NET which is why Unity uses it.

    The vast majority of the readings you'll find related to C# will work in Unity unless the topic they cover is exotic or new.
     
  8. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    Spot on.
     
  9. BCrisos

    BCrisos

    Joined:
    Jan 8, 2015
    Posts:
    52
    KelsoMRK, Baste, & draxov
    Thank you so much guys! This has been a big help to me! Cleared up a lot of things when it came to understanding of C#, The Syntax and Unity. If I have anymore questions i'll come to the forums and post you guys are great!
     
    draxov likes this.