Jump to content

Trying to learn c#

eike93

So i'm trying to learn c#, but i'm having problems learning it by myself. So i was hoping anyone here would like to jump on teamspeak and help me ? 

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, M.Yurizaki said:

What are you having trouble with?

So i learn easier by doing and i'm having a problem remembering everything, so i guess i'm looking for a cheat sheet with the basics.

 

Also the book i was recommended totally skipped int and how to set it up

Link to comment
Share on other sites

Link to post
Share on other sites

On 07/12/2016 at 7:12 PM, eike93 said:

So i learn easier by doing and i'm having a problem remembering everything, so i guess i'm looking for a cheat sheet with the basics.

 

Also the book i was recommended totally skipped int and how to set it up

 
 
 
 

Here's your cheatsheet:

https://en.wikipedia.org/wiki/C_Sharp_syntax

 

as for int:


int x; // x == 0

int x = 1; // x == 1

Aragorn (WS): 250D | 6800k | 840 Pro 512GB | Intel 530 480GB  | Asus X99-M WS | 64GB DDR4 | Corsair HX720i | GTX 1070 | Corsair H115i | Philips BDM4350UC 43" 3840x2160 IPS

Gimli (server):  Node 304 | G4560 | ADATA XPG SX8000 128GB | 2x 5TB WD Red | ASROCK H270M-ITX/AC  | 8GB DDR4 | Seasonic 400FL

 Omega (server):                 Fractal Arc Mini R2 | i3 4130 | 500GB Maxtor | 2TB WD Red : Raid 1 | 3TB Seagate Barracuda | 16GB RAM | Seasonic G-450w
Alpha (WS): 900D | 4770k | GTX 780  | 840 Pro 512GB  | GA-Z87X-OC | Corsair RM 850 | 24GB 2400mhz | Samsung S27B970D 2560x1440

                              ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Link to comment
Share on other sites

Link to post
Share on other sites

41 minutes ago, eike93 said:

So i learn easier by doing and i'm having a problem remembering everything, so i guess i'm looking for a cheat sheet with the basics.

 

Also the book i was recommended totally skipped int and how to set it up

Microsoft has a documentation aplenty online. C# documentation is one of the best of any language.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, squirrl said:

as for int:

int x; // x == 0

int x = 1; // x == 1

Actually it's not that simple.

 

Local variables aren't automatically initialized with a default value. So int x; will give you a compilation error if you try to use it before it's assigned a value.

// This doesn't work. It gives you a compilation error
static void Main(string[] args)
{
    int i;
    bool b = (i == 0);
}

// This works
static void Main(string[] args)
{
    int i = 0;
    bool b = (i == 0);
}

// This works too
static void Main(string[] args)
{
    int i;
    i = 0;
    bool b = (i == 0);
}

Fields/properties are automatically initialized with a default value when the class is instantiated.

// This works
public class Test
{
    private int i; // defaults to zero
    private double d { get; set; } // also defaults to zero
  
    public Test()
    {
        bool b = (i == 0);
    }
}

 

Link to comment
Share on other sites

Link to post
Share on other sites

Most people, like me, remember things like that by doing. So just think of a simple thing you'd do, figure the algorithm out, and if you don't know something, just google it out!

If you are already familiar with the concepts, and just want to refresh your syntax knowledge, I recommend you Derek's videos:

 

Link to comment
Share on other sites

Link to post
Share on other sites

On 07/12/2016 at 10:56 PM, madknight3 said:

Actually it's not that simple.

 

Local variables aren't automatically initialized with a default value. So int x; will give you a compilation error if you try to use it before it's assigned a value.

Fields/properties are automatically initialized with a default value when the class is instantiated.

 

1

Right! Most of my C# recently has been only from within classes, so I overlooked this!

Aragorn (WS): 250D | 6800k | 840 Pro 512GB | Intel 530 480GB  | Asus X99-M WS | 64GB DDR4 | Corsair HX720i | GTX 1070 | Corsair H115i | Philips BDM4350UC 43" 3840x2160 IPS

Gimli (server):  Node 304 | G4560 | ADATA XPG SX8000 128GB | 2x 5TB WD Red | ASROCK H270M-ITX/AC  | 8GB DDR4 | Seasonic 400FL

 Omega (server):                 Fractal Arc Mini R2 | i3 4130 | 500GB Maxtor | 2TB WD Red : Raid 1 | 3TB Seagate Barracuda | 16GB RAM | Seasonic G-450w
Alpha (WS): 900D | 4770k | GTX 780  | 840 Pro 512GB  | GA-Z87X-OC | Corsair RM 850 | 24GB 2400mhz | Samsung S27B970D 2560x1440

                              ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Link to comment
Share on other sites

Link to post
Share on other sites

I really think you just need to take your time. Accept that it's not easy to learn a programming language.

 

Watch some YouTube videos (there are tons), and mess around in Visual Studio as much as you can.

 

Accept that you might not understand everything and don't pretend you do. Come back to certain topics later, with a broader knowledge it will be easier to understand more deeply.

 

And programming isn't so much about remembering. Focus on understanding topics, and get good at searching for help on Google and Stackoverflow.

Link to comment
Share on other sites

Link to post
Share on other sites

On ‎12‎/‎8‎/‎2016 at 6:56 AM, madknight3 said:

Actually it's not that simple.

 

Local variables aren't automatically initialized with a default value. So int x; will give you a compilation error if you try to use it before it's assigned a value.


// This doesn't work. It gives you a compilation error
static void Main(string[] args)
{
    int i;
    bool b = (i == 0);
}

// This works
static void Main(string[] args)
{
    int i = 0;
    bool b = (i == 0);
}

// This works too
static void Main(string[] args)
{
    int i;
    i = 0;
    bool b = (i == 0);
}

Fields/properties are automatically initialized with a default value when the class is instantiated.


// This works
public class Test
{
    private int i; // defaults to zero
    private double d { get; set; } // also defaults to zero
  
    public Test()
    {
        bool b = (i == 0);
    }
}

 

Visual Studio won't throw an error though. It'll just assign a generic value of 0.

Judge a product on its own merits AND the company that made it.

How to setup MSI Afterburner OSD | How to make your AMD Radeon GPU more efficient with Radeon Chill | (Probably) Why LMG Merch shipping to the EU is expensive

Oneplus 6 (Early 2023 to present) | HP Envy 15" x360 R7 5700U (Mid 2021 to present) | Steam Deck (Late 2022 to present)

 

Mid 2023 AlTech Desktop Refresh - AMD R7 5800X (Mid 2023), XFX Radeon RX 6700XT MBA (Mid 2021), MSI X370 Gaming Pro Carbon (Early 2018), 32GB DDR4-3200 (16GB x2) (Mid 2022

Noctua NH-D15 (Early 2021), Corsair MP510 1.92TB NVMe SSD (Mid 2020), beQuiet Pure Wings 2 140mm x2 & 120mm x1 (Mid 2023),

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, AluminiumTech said:

Visual Studio won't throw an error though. It'll just assign a generic value of 0.

Using an unassigned local variable does throw an error in Visual Studio for me.

 

If the variable isn't used, it'll display a warning, but it'll compile and run fine (by default, you can have Visual Studio treat warnings as errors if you choose).

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×