8: How To Create Static Methods In C# | Static Method | C# Tutorial For Beginners | C Sharp Tutorial

8: How To Create Static Methods In C# | Static Method | C# Tutorial For Beginners | C Sharp Tutorial

Dani Krossing

5 лет назад

80,512 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Dia'sChallengeZone
Dia'sChallengeZone - 07.08.2023 13:24

Ur example method is static but u acess non static members inside it?

Ответить
Madhavi Patil
Madhavi Patil - 09.11.2022 20:54

thanks for making the static class understanding easier 😇

Ответить
Vinicius De Moraes Nascimento
Vinicius De Moraes Nascimento - 15.10.2022 22:12

Great, thank you Dani!

Ответить
M Maranta
M Maranta - 05.08.2022 07:04

Your videos are great!

Ответить
Fredoh
Fredoh - 25.06.2022 16:35

I been learning how to code for the past 2 months and i have to admit that your videos are very helpful! Thank You!

Ответить
Zeina zip
Zeina zip - 22.12.2021 19:17

The best !!
Thank you for the amazing explanation 👏👏

Ответить
Pirate Skeleton
Pirate Skeleton - 16.11.2021 00:28

Weird use case for why you would want to instantiate a class that only holds functions, say you are calling thousands of asynchronous methods that may end up trying to run concurrently, a static class function call may actually become a bottleneck since it can only be called once at a time.

Ответить
Erfan Ebtia
Erfan Ebtia - 24.10.2021 12:20

Hello Sir, but tell me why we need a static method for calculator , what is the purpose?
I mean we could use the objects and a Structure method!!

Ответить
Z M
Z M - 28.09.2021 11:01

Another great video, nice the way you clarify things to keep it as simple as possible and you're happy to reiterate it. Sign of a good teacher

Ответить
Fghyt Sgyu
Fghyt Sgyu - 04.09.2021 23:09

Hi Dani, the videos of your programming teaching series are very helpful for me to learn programming by myself. Can you make this film produce subtitles? Thank you.

Ответить
Regal_7
Regal_7 - 10.08.2021 05:50

So basically static methods are similar to normal global functions in C...but a little more complicated? Just that in c# everything is object oriented so it has to be withing a namespace & class. Static functions in C are a different thing though. What about private static methods in C#. How will that work?

Ответить
poopy_fingers
poopy_fingers - 24.07.2021 18:26

why did you create variables int x and int y and then immediately create new int variables to assign to x and y?

Ответить
Hamza Shreef
Hamza Shreef - 07.07.2021 01:38

Please! Keep making such tutorials in C# OOP because they are useful , amazing and unique.

Ответить
djordje3d
djordje3d - 18.06.2021 15:56

Perfect systematic transfer of knowledge! Bravo!

Ответить
Bulxan Boos
Bulxan Boos - 06.06.2021 07:37

You are on fire sir. Great thanks from Somalia.

Ответить
LordSevla
LordSevla - 19.05.2021 18:21

I'm glad you speak english and I'm glad I can understand english. I already paid for content worse than this.

Ответить
guardian218
guardian218 - 04.04.2021 21:14

Thank you for explaining this topic so well!

Ответить
HRB GTC India
HRB GTC India - 15.03.2021 17:18

Who else thinks he looks like Elon Musk ? :D

Ответить
Sarah Modhfar
Sarah Modhfar - 17.02.2021 11:00

Good job, keep going .

Ответить
bluefyr22
bluefyr22 - 01.01.2021 01:25

So for people who like me forgot from his earlier video you have to tell CS that you are using the calc name space by putting it up above under "using System;" i put it as "using FirstProject.Calc;" without the quotes

Ответить
Miquel
Miquel - 10.12.2020 00:02

Excellent teacher, one question. What do you mean with object, I still don't really get it, but I understood this episode.

Ответить
Kevin Mungame
Kevin Mungame - 24.11.2020 10:10

Well done. Thank you

Ответить
Omer Farooq
Omer Farooq - 30.08.2020 14:45

you just make me more confused.....because when telling the purpose of both cases you just run so fasttt

Ответить
Ðragøn
Ðragøn - 07.07.2020 20:07

I know this video is over a year old, but I've got a question and I hope you or anyone else could help me with it.
Can I still access the method of add when I make the calculator object or not? When I tried to create a calculator object and than tried the method it didn't work, I assume this is I can't add the values for x and y? But I'm not sure.

Ответить
Mohamed Abutaloula
Mohamed Abutaloula - 06.06.2020 15:52

You’re awesome 👏

Ответить
Darrell Ong
Darrell Ong - 04.05.2020 10:08

the way you explain it makes for sense than that udemy guy.

Ответить
Craig Spolander
Craig Spolander - 01.05.2020 22:22

I'm probably very wrong, but hopefully you can correct me. Right in the beginning, when you say you created a "Namespace" called Calc, is that not just a folder containing custom classes? or is my understanding wrong (definitely), I'm new to this and the concept of a namespace still confuses me.

Ответить
Dillon panter
Dillon panter - 27.04.2020 17:58

subscribed.

Ответить
bUbBle gUm
bUbBle gUm - 25.04.2020 10:37

random question n e 1: if cap on second word is camelCase, what's the name of "_" prefix for _private variables?

Ответить
Tariku Dereje
Tariku Dereje - 30.01.2020 15:12

i'm still enjoying with all of your vidios.

Ответить
Avantha Chandrasena
Avantha Chandrasena - 17.01.2020 09:25

A perfect explanation!

Ответить
Anne E
Anne E - 02.01.2020 02:32

Hello @mmtuts, Godt nyttår :-)
Can we just write the following code for calculator.cs?
```

using System;
namespace FirstProject.Calc
{
public class Calculator
{
public static int Add(int x, int y)
{
int Answer = x + y;
return Answer;
}
}
}

```
(I ditched the step with int Num1 = x and int Num2 = y)
Seems to work for me? Or is it a no-no to simplify like I did, and if so, why?
Cheers :-)

Ответить
Jesse Foster
Jesse Foster - 11.12.2019 23:10

Thank you so much! I'm a student learning C# for my courses, and I was really struggling with refactoring my code via creating methods. This was a HUGE help!

Ответить
Ahmed
Ahmed - 08.12.2019 15:16

Should have given an example of a non-static class in the video and compared both with a practical example.

Ответить
Bruce Harrison Jr.
Bruce Harrison Jr. - 26.11.2019 05:23

so far so good, you are a really good teacher

Ответить
Taylor Horn
Taylor Horn - 08.11.2019 00:03

Thank you for explaining this for normal human understanding 😂

Ответить
Jussi Aho
Jussi Aho - 30.10.2019 02:09

You are great MAN!

Ответить
mrArk
mrArk - 26.10.2019 11:09

i like the way you explain sir..it is clear. im new to c#. also if you're done covering all the crucial parts for c#, can you make tuto for wpf? Tnx in advance

Ответить
Dwayne Osei-kofi
Dwayne Osei-kofi - 10.09.2019 13:38

I enjoy your videos, thanks for helping. Keep up the good work.

Ответить
grayfoxfive
grayfoxfive - 19.08.2019 17:24

Apologies if this was somehow posted earlier, but I'm trying to wrap my head around this idea of static methods. Coming from a background in VB and VBA, this just seems to me like static methods are really nothing more than the equivalent of procedures and functions in VB. Whereas in C# you would create a public class (which is really nothing more than a container in this context), then a public method, in VBA the equivalent would be to add a code module, then write procedures and functions inside it, a procedure to simply "do" something (e.g. static void), and a function to "return" something (e.g. static string), both known as methods in C#. Granted, I know this has nothing to do with instantiation or objects, but for the purposes of what's discussed in this video, am I correct in my understanding?

Ответить
A K
A K - 18.07.2019 20:52

watching ur videos to learn csharp, thanx

Ответить
karacter33
karacter33 - 19.06.2019 01:35

finaly understood oof

Ответить
Aurorah
Aurorah - 25.03.2019 22:15

Your thumbnails are always so welcoming

Ответить
Tom Retterath
Tom Retterath - 25.03.2019 18:46

As always a great help. Thanks mate!

Ответить
Ryan Crnich
Ryan Crnich - 25.03.2019 18:38

Dude just make the phone videos

Ответить
idris
idris - 25.03.2019 18:32

Nice video

Ответить
Manav Sharma
Manav Sharma - 25.03.2019 18:30

Absolutely Amazing. , You are the reason I started to like the idea of becoming developer. Thanks a lot for all this great work and help.

Ответить